akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ii>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a);  a = (a * a);  b/=2;  }  return res; }
#define rs resize
long long readLI(){  register char c;  for(c = getchar(); !(c>='0' && c<='9'); c = getchar());  register long long a=c-'0';
    for(c = getchar(); c>='0' && c<='9'; c = getchar())
        a = (a<<3)+(a<<1)+c-'0';
    return a;
}
const ll N = 1009;
ll n,m,i,j;
bool flag,pos;
string a,b;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>a>>b;
    n = a.length(); m = b.length();
    revrep(i,n - 1,0){
         flag = true;
         if(i + m - 1 >= n) continue;
         for(j = 0;j < m;j++){
             if(a[i + j] == '?' or (a[i + j] == b[j])) continue;
             flag = false;
             break;
         }
        if(flag){
            pos = true;
            for(j = 0;j < m;j++) a[i + j] = b[j];
            break;
        }
    }
    if(not pos) cout<<"UNRESTORABLE";
    else{
       rep(i,0,n) if(a[i] == '?') a[i] = 'a';
       cout<<a;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
#ifdef LOCAL
mt19937 rng(unsigned(70));
#else
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#endif
#define rand rng


int main() {
	// fios;
	int n, m;
	cin >> n >> m;
	vector<int> h(n);
	for(auto& x: h) cin >> x;

	vector<vector<int>> adj(n);
	
	for(int v, u, i = 0; i < m; i++) {
		cin >> u >> v;
		--u, --v;
		if(h[u] <= h[v])
			adj[u].push_back(v);
		if(h[v] <= h[u])
			adj[v].push_back(u);
	}

	int ans = 0;
	for(int i = 0; i < n; i++) {
		if(adj[i].empty()) ans++;
	}
	cout << ans << endl;

}

Measured memory_bytes: 7736
#include <stdio.h>
#define MOD 1000000007
typedef long long int ll;
ll PMRS(ll N, ll P, ll M){
	if (P == 0){
		return 1;
	}else if (P % 2 == 0){
		ll t = PMRS(N, P/2, M); 
		return t * t % M;
	}else{
		return N * PMRS(N, P - 1, M) % M;
	}
}  

ll inv_Felmat(ll a, ll M){
	return PMRS(a, M - 2, M);
}

ll perm(ll n, ll k, ll M){
	if (k == 1) return n;
	return perm(n, k - 1, M) * (n - k + 1) % M;
}

ll comb(ll n, ll k, ll M){
	ll x = perm(n, k, M);
	ll y = perm(k, k, M);
	return x * inv_Felmat(y, M);
}
int main(){
  ll n, a, b, ans;
  scanf("%lld%lld%lld", &n, &a, &b);
  ans = (PMRS(2, n, MOD) - 1) % MOD;
  ans = (ans - comb(n, a, MOD)) % MOD;
  ans = (ans - comb(n, b, MOD)) % MOD;
  while (ans < 0)	ans += MOD;
  printf("%lld", ans);
}

Measured memory_bytes: 6400
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<list>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int main() {
	for (int n; cin >> n&&n;) {
		int a = 0, b = 0;
		while (n) {
			for (int i = 1; (n % (5 * i)) == 0; i *= 5) a++;
			for (int i = 1; (n % (2 * i)) == 0; i *= 2) b++;
			n--;
		}
		cout << min(a, b) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<ll> v(N);
    rep(i,N) cin >> v[i];
    sort(v.begin(), v.end());
    int ans = 0;
    for(int mid = N - 1; mid >= 0; mid--) {
        for(int low = mid - 1; low >= 0; low--) {
            //v[mid] + v[low]　以上の最初のイテレータ
            auto itr = lower_bound(v.begin(), v.end(), v[mid] + v[low]);
            //itrから最後までの個数
            int ng = distance(itr, v.end());
            ans += (N - 1 - mid) - ng;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

ll a, b, c;

int main() {
    cin >> a >> b >> c;

    if (c - a - b < 0) {
        cout << "No" << '\n';
        return 0;
    }
    if (4 * a* b < (c - a - b) * (c - a - b)) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<pair<int,int>>a[n];
  rep(i,n){
    int k;
    cin>>k;
    rep(j,k){
      int s,t;
      cin>>s>>t;
      s--;
      a[i].push_back(pair<int,int>(s,t));
    }
  }
  
  int ans=0;
  for (int tmp = 0; tmp < (1 << 15); tmp++) {
    bitset<15> s(tmp);
    bool ex=true;
    int now=0;
    rep(i,n){
      if(s.test(i)){
        rep(j,a[i].size()){
          if(a[i].at(j).second==1){
            if(!s.test(a[i].at(j).first)){
              ex=false;
              break;
            }
          }
          else{
            if(s.test(a[i].at(j).first)){
              ex=false;
              break;
            }
          }
        }
      }
    }
    if(ex){
      rep(i,n){
        if(s.test(i)){
          now++;
        }
      }
    }
    ans=max(ans,now);
  }
    
  cout<<ans<<endl;  
}



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

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

const int a[]={0,1,2,4,7,12,20,29,38,52,73};
int n,p[N];
ll G[N][N];

int main() {
	cin>>n;ll m=0;
	for(int i=2;i<=n;i++) {
		for(int j=1;j<i;j++) G[i][j]=G[j][i]=(m+1)*a[j];
		if(i==n) break;
		for(int j=1;j<=i;j++) p[j]=j;
		do {
			ll sum=0;
			for(int j=1;j<i;j++) sum+=G[p[j]][p[j+1]];
			m=max(m,sum);
		} while(next_permutation(p+1,p+i+1));
	}
	for(int i=1;i<=n;i++,cout<<'\n')
		for(int j=1;j<=n;j++) cout<<G[i][j]<<' ';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

constexpr int MOD = 1000000007;

int main()
{
    int N, K;
    cin >> N >> K;

    vector<int> vp;
    int i = 1;
    while (i <= N / i)
    {
        vp.emplace_back(i);
        vp.emplace_back(N / i);
        i++;
    }
    sort(vp.begin(), vp.end());

    vector<lint> dp(vp.size());
    dp[0] = 1;
    REP(_, K)
    {
        vector<lint> dp_new(vp.size());
        REP(i, vp.size())
        {
            (dp_new[vp.size() - 1 - i] += dp[i]) %= MOD;
        }
        IREP(i, dp_new.size() - 1) (dp_new[i] += dp_new[i + 1]) %= MOD;
        REP(i, dp_new.size())
        {
            dp_new[i] = dp_new[i] * (i == 0 ? 1 : vp[i] - vp[i - 1]) % MOD;
        }
        swap(dp, dp_new);
    }
    lint ret = accumulate(dp.begin(), dp.end(), 0LL);
    cout << ret % MOD << endl;
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

/*ll gcd(ll x, ll y) {
  if(y == 0) return x;
  else return gcd(y, x%y);
}*/

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll a, b;
  cin >> a >> b;
  
  ll n = __gcd(a, b);
  
  cout << a*b/n << "\n";

}


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

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

    int a, b;
    int da, db;
    int ans = 1;

    for (int i = 0; i < n; i++) {
        cin >> b;

        if (i == 0) {
            a = b;
            da = 0;
        }

        db = (a == b ? 0 : (a > b ? -1 : 1));

        if ((da > 0 && db < 0) || (da < 0 && db > 0)) {
            ans++;
            da = 0;
        } else if (db != 0) {
            da = db;
        }

        a = b;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

template<int MOD>
class ModInt{
public:
    ModInt():value(0){}
    ModInt(long long val):value((int)(val<0?MOD+val%MOD:val%MOD)){ }

    ModInt& operator+=(ModInt that){
        value = value+that.value;
        if(value>=MOD)value-=MOD;
        return *this;
    }
    ModInt& operator-=(ModInt that){
        value -= that.value;
        if(value<0)value+=MOD;
        return *this;
    }
    ModInt& operator*=(ModInt that){
        value = (int)((long long)value * that.value % MOD);
        return *this;
    }
    ModInt &operator/=(ModInt that){
        return *this *= that.inverse();
    }
    ModInt operator+(ModInt that) const{
        return ModInt(*this)+=that;
    }
    ModInt operator-(ModInt that) const{
        return ModInt(*this)-=that;
    }
    ModInt operator*(ModInt that) const{
        return ModInt(*this)*=that;
    }
    ModInt operator/(ModInt that) const {
        return ModInt(*this) /= that;
    }
    ModInt pow(long long k) const{
        if(value == 0)return 0;
        ModInt n = *this, res = 1;
        while(k){
            if(k & 1)res *= n;
            n *= n;
            k >>= 1;
        }
        return res;
    }
    ModInt inverse() const {
        long long a = value, b = MOD, u = 1, v = 0;
        while(b) {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }
    int toi() const{ return value; }

private:
    int value;
};
typedef ModInt<1000000007> mint;
ostream& operator<<(ostream& os, const mint& x){
    os << x.toi();
    return os;
}

template <class Val>
vector<Val> factorials(int n){
    vector<Val> res(n + 1);
    res[0] = res[1] = 1;
    for(int i = 2; i <= n; ++i)
        res[i] = res[i - 1] * i;
    return res;
}

vector<mint> F;
mint calc(int x, int y) {
    return F[x + y] / (F[x] * F[y]);
}

int main(){
    F = factorials<mint>(200000);
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    mint ans = calc(H - 1, W - 1);
    for(int x = 1; x <= B; ++x) {
        ans -= calc(H - A - 1, x - 1) * calc(A - 1, W - x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
aplusi = [item+i for i,item in enumerate(a)]
iminusa = [i-item for i,item in enumerate(a)]
c1 = Counter(aplusi)
c2 = Counter(iminusa)
out = 0
for k,v in c1.items():
    if k in c2:
        out += v * c2[k]
print(out)

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

const int N=210;
int n;
LL a[N];
char str[N];
struct Base {
	LL arr[62];
	void init() { memset(arr,0,sizeof(arr)); }
	void ins(LL x) {
		for(int i=61;~i;--i)
			if(x>>i&1) {
				if(!arr[i]) { arr[i] = x; break; }
				else x ^= arr[i];
			}
	}
	bool find(LL x) {
		for(int i=61;~i;--i)
			if(x>>i&1) x ^= arr[i];
		return x == 0;
	}
} A;
int main() {
	int T; scanf("%d",&T);
	while(T--) {
		scanf("%d",&n);
		for(int i=1;i<=n;++i)
			scanf("%lld",&a[i]);
		scanf("%s",str+1);
		A.init();
		bool ans=0;
		for(int i=n;i>=1;--i) {
			if(str[i] == '0') A.ins(a[i]);
			else ans |= !A.find(a[i]);
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int c[5000], r[5000];
vector<int>e[5000], E[5000];
int d[5000];

int main() {
	int n, k; cin >> n >> k;
	rep(i, n)scanf("%d%d", &c[i], &r[i]);
	rep(i, k){
		int a, b; scanf("%d%d", &a, &b);
		e[--a].push_back(--b); e[b].push_back(a);
	}
	queue<P>que;
	rep(i, n) {
		d[i] = true;
		que.push(P(i, 0));
		while (!que.empty()) {
			int f = que.front().first, s = que.front().second; que.pop();
			if (s == r[i])continue;
			rep(j, e[f].size()) {
				if (d[e[f][j]])continue;
				d[e[f][j]] = true;
				E[i].push_back(e[f][j]);
				que.push(P(e[f][j], s + 1));
			}
		}
		if (i == n - 1)memset(d, 0x3f, sizeof(d));
		else memset(d, 0, sizeof(d));
	}
	priority_queue<P, vector<P>, greater<P>>pque;
	pque.push(P(0, 0));
	d[0] = 0;
	while (!pque.empty()) {
		P p = pque.top(); pque.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		rep(i, E[v].size()) {
			int edge = E[v][i];
			if (d[edge] > d[v] + c[v]) {
				d[edge] = d[v] + c[v];
				pque.push(P(d[edge], edge));
			}
		}
	}
	cout << d[--n] << endl;
}

Measured memory_bytes: 70780
N,M=map(int,input().split())
A=list(list(input()) for _ in range(N))
B=list(list(input()) for _ in range(M))
flag=False
for i in range(0,N-M+1):
    for j in range(0,N-M+1):
        sub=True
        for x in range(0,M):
            for y in range(0,M):
                if A[i+x][j+y]!=B[x][y]:
                    sub=False
        flag=flag or sub
if flag:
    print("Yes")
else:
    print("No")


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

class mint {
  private: 
    ll x;

  public:
    constexpr mint(const ll x = 0) noexcept : x((x % mod + mod) % mod) {}
    constexpr ll value() noexcept { return x; }
    constexpr mint operator += (const mint right) noexcept {
      if ((x += right.x) >= mod) x -= mod;
      return *this;
    }
    constexpr mint operator -= (const mint right) noexcept {
      if ((x += mod - right.x) >= mod) x -= mod;
      return *this;
    }
    constexpr mint operator *= (const mint right) noexcept {
      x = x * right.x % mod;
      return *this;
    }
    constexpr mint operator /= (const mint right) noexcept {
      return *this *= right.inv();
    }
    constexpr mint operator + (const mint right) const noexcept {
      return mint(*this) += right;
    }
    constexpr mint operator - (const mint right) const noexcept {
      return mint(*this) -= right;
    }
    constexpr mint operator / (const mint right) const noexcept {
      return mint(*this) /= right;
    }
    constexpr mint operator * (const mint right) const noexcept {
      return mint(*this) *= right;
    }
    constexpr mint inv() const {
      return pow(mod-2);
    }
    constexpr mint pow(ll n) const {
      if (n == 0) return 1;
      mint a = pow(n>>1);
      a *= a;
      if (n & 1) a *= *this;
      return a;
    }
};

signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, k; cin >> n >> k;
  mint ans = 0;

  rep2(i, k, n+1) {
    ll left = (i * (i + 1)) / 2;
    ll right = i * (3 + (2 * n) - i) / 2;

    ans += right - left + 1;
  }

  cout << ans.value() << endl;
}


Measured memory_bytes: 3644
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;
 
long long gcd(long long x, long long y){
			if (x==0)return y;
      if(y==0)return x;
      if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

   
int main(){
	string S;
	cin >> S;
	string sub = S.substr(0,2);
	int num_f = stoi(sub);
	int num_b = stoi(S.substr(2,2));
	
	bool MM_f=false;
	bool MM_b=false;
	if(num_f<=12&&num_f!=0)MM_f=true;
	if(num_b<=12&&num_b!=0)MM_b=true;
	if(MM_f&&MM_b)cout <<"AMBIGUOUS" << endl;
	else if(MM_b == false&&MM_f==false)cout << "NA"<<endl;
	else if(MM_b)cout<<"YYMM"<<endl;
	else cout << "MMYY" <<endl;
		
}





Measured memory_bytes: 256
object Main extends App {
  val n: Int = io.StdIn.readInt()
  val Seq(i, l, r): Seq[Int] = io.StdIn.readLine().split(" ").map(_.toInt)
  val tree: Array[(Int, Int)] = Array.fill(n)((-1, -1))
  val parent: Array[Option[Int]] = Array.fill(n)(None)
  tree(i) = (l, r)
  for (_ <- 1 until n) {
    val Seq(i,l,r): Seq[Int] = io.StdIn.readLine().split(" ").map(_.toInt)
    tree(i) = (l, r)
    if (l != -1) parent(l) = Some(i)
    if (r != -1) parent(r) = Some(i)
  }

  def find_root(c: Int): Int = parent(c) match {case None => c ; case Some(p) => find_root(p)}
  def order(c: Int)(f: (Int, List[Int], List[Int]) => List[Int]): List[Int] = {
    if (c == -1) Nil
    else {
      val (l, r) = tree(c)
      f(c, order(l)(f), order(r)(f))
    }
  }
  def preorder(rn: Int): List[Int] = order(rn)((i, l, r) => i :: (l ::: r))
  def inorder(rn: Int): List[Int] = order(rn)((i, l, r) => l ::: (i :: r))
  def postorder(rn: Int): List[Int] = order(rn)((i, l, r) => l ::: r ::: List(i))

  val root: Int = find_root(i)
  println(s"Preorder\n ${preorder(root).mkString(" ")}\nInorder\n ${inorder(root).mkString(" ")}\nPostorder\n ${postorder(root).mkString(" ")}")
}


Measured memory_bytes: 44056
class dice:
    men = [0] * 7
    def __init__(self, li):
        self.men = [0] + li
    def move(self, h):
        if h == "N":
            t = self.men[1]
            self.men[1] = self.men[2]
            self.men[2] = self.men[6]
            self.men[6] = self.men[5]
            self.men[5] = t
        elif h == "S":
            t = self.men[1]
            self.men[1] = self.men[5]
            self.men[5] = self.men[6]
            self.men[6] = self.men[2]
            self.men[2] = t
        elif h == "W":
            t = self.men[1]
            self.men[1] = self.men[3]
            self.men[3] = self.men[6]
            self.men[6] = self.men[4]
            self.men[4] = t
        elif h == "E":
            t = self.men[1]
            self.men[1] = self.men[4]
            self.men[4] = self.men[6]
            self.men[6] = self.men[3]
            self.men[3] = t
saikoro = dice(list(map(int, input().split())))
for s in input():
    saikoro.move(s)
print(saikoro.men[1])



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

int main() {
  int a,b; cin >> a >> b;
  if (a == b) cout << "Draw" << endl;
  else {
    if (a == 1) cout << "Alice" << endl;
    else if (b == 1) cout << "Bob" << endl;
    else {
      if (a > b) cout << "Alice" << endl;
      else cout << "Bob" << endl;
    }
  }
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right != NIL)
    x = x->right;
  return x;
}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)
    return treeMinimum(x->right);

  y = x->parent;

  while(y != NIL && x == y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y; // node to be deleted 
    Node x; // child of y                                                                          



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;

  if(y == NIL)
    root = z;
  else if(z->key < y->key)
    y->left = z;
  else
    y->right = z;
}

void inorder(Node u){
  if(u != NIL){
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u != NIL){
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}


Measured memory_bytes: 25180
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        if (k <= data[i]) {
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    set<string>t;
    bool flag=true;
    bool flag1=true;
    string s1;
    for(i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(flag==false)
        {
            if(s[0]!=s1[s1.size()-1])
            {
            flag1=false;
            }
        }
        s1=s;
        t.insert(s);
        flag=false;
    }
    if(flag1==false)
    {
        cout<<"No";
        return 0;
    }
    if(t.size()!=n)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }
}


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


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

	int N;
	cin >> N;

	deque<ll> a(3 * N);
	for(int i = 0; i < 3 * N; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	ll ans = 0;
	for(int i = N; i < 2 * N; i++) {
		a.pop_back();
		a.pop_front();
		ans += a.back();
		a.pop_back();
	}
	cout << ans << endl;
}

Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {

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

		int N = sc.nextInt();
		int x = 0, y = 0, z = 0;

		int cnt = 0;
		for (int i = 0; i < N; i++) {
			String s = sc.next();

			//A---B
			for (int j = 0; j < s.length() - 1; j++) {
				if(s.charAt(j) == 'A' && s.charAt(j + 1) == 'B') cnt++;
			}

			if(s.charAt(0) == 'B' && s.charAt(s.length() - 1) == 'A') x++;		//B---A
			else if(s.charAt(s.length() - 1) == 'A') y++;	//----A
			else if(s.charAt(0)== 'B') z++;	//B----

		}

		int ans = 0;
		if (x != 0) {
			if(y == 0 && z == 0)
				ans = x - 1;
			else
				ans = Math.min(y, z) + x;
		} else {
			ans = Math.min(y, z);
		}

		//System.out.println(cnt + " " + x + " " + y + " " + z);

		System.out.println(ans + cnt);
	}

}

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

int main(){
 int a,b,c;
 int min,center,top;
 cin>>a>>b>>c;
 if(a>b&&a>c){
  top=a;
  if(b>c){
   center=b;
   min=c;
  }else{
   center=c;
   min=b;
  }
 }

 if(b>a&&b>c){
  top=b;
  if(a>c){
   center=a;
   min=c;
  }else{
   center=c;
   min=a;
  }
 }

 if(c>a&&c>b){
  top=c;
  if(c>a&&c>b){
   if(a>b){
    center=a;
    min=b;
   }else{
    center=b;
    min=a;
   }
  }
 }
 cout<<min<<' '<<center<<' '<<top<<'\n';
 return 0;
}

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

main(){
	
	int n,m,p,pos ;
	int c[20020] ;
	cin >> n >> m >> p ;
	for( int i=0 ; i<m ; i++ ){
		cin >> c[i*2] ;
		c[i*2+1] = c[i*2] + n ;
	}
	c[m*2] = p ;
	c[m*2+1] = p + n ;
	m++ ;
	sort(c,c+m*2) ;
	for( int i=0 ; i<m*2 ; i++ ){
		if( c[i] == p ){
			pos = i ;
			break ;
		}
	}
	
	int ans = c[m+pos] - c[pos+1] ;
	for( int i=1 ; i<m ; i++ ){
		int sum1 = c[pos+i] - c[pos] ;
		int sum2 = c[m+pos] - c[pos+i+1] ;
		if( sum1 < sum2 ) sum1 *= 2 ;
		else sum2 *= 2 ;
		
		ans = min( ans , sum1 + sum2 ) ;
	}
	
	cout << ans*100 << endl ;
}

Measured memory_bytes: 1252
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] a = sc.next().split("/");
        String correct = "2018";
        a[0] = correct;
        System.out.println(a[0] + "/" + a[1] + "/" + a[2] );
    }
}


Measured memory_bytes: 21460
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
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> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int main(){
	int n;
	while(cin>>n,n){
		vvi ok(n,vi(30));
		REP(i,n){
			int f;
			cin>>f;
			REP(j,f){
				int d;
				cin>>d;
				ok[i][d-1]=1;
			}
		}
		if(n==1){
			cout<<1<<endl;
		}else{
			vector<set<int> > maps(n);
			REP(i,n){
				maps[i].insert(i);
			}
			int ans=-1;
			REP(day,30){
				set<int> m;
				REP(i,n){
					if(ok[i][day]){
						m.insert(ALL(maps[i]));
					}
				}
				if(m.size()==n){
					ans=day+1;
					break;
				}
				REP(i,n){
					if(ok[i][day]){
						maps[i]=m;
					}
				}
			}
			cout<<ans<<endl;
		}
	}
}

Measured memory_bytes: 1344
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		String[] tarou = new String[n];
		String[] hanako = new String[n];
		int tarou_score = 0;
		int hanako_score = 0;
		for(int i=0;i<n;i++){
			tarou[i] = stdIn.next();
			hanako[i] = stdIn.next();
		}
		
		for(int i=0;i<n;i++){
			if(tarou[i].compareTo(hanako[i])>0){
				tarou_score += 3;
			}
			else if(tarou[i].compareTo(hanako[i])<0){
				hanako_score += 3;
			}
			else{
				tarou_score += 1;
				hanako_score += 1;
			}
		}
		
		System.out.println(tarou_score+" "+hanako_score);
	}
}

Measured memory_bytes: 20884
#include <iostream>
#include <vector>

using namespace std;

using Int = long long;

int main() {
	Int N, M, C, ans, count = 0;
	cin >> N >> M >> C;
	vector<Int> B(M);
	for(Int i = 0; i < M; i++) {
		cin >> B[i];
	}
	vector<vector<int>> A(N);
	for(Int i = 0; i < N; i++) {
		A[i].resize(M);
	}
	for(Int i = 0; i < N; i++) {
		for(Int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}
	ans = 0;
	for(Int i = 0; i < N; i++) {
		for(Int j = 0; j < M; j++) {
			ans += A[i][j]*B[j];
		}
		if(ans + C > 0) count++;
		ans = 0;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
class CustomArray:
    def __init__(self, sz):
        self.sz = sz
        self.vals = {}

    def size(self):
        return self.sz

    def assign(self, idx, val):
        if idx == None or val == None:
            return False
        if idx >= self.sz:
            return False
        self.vals[idx] = val
        return True
    
    def get(self, idx):
        if idx == None:
            return None
        if idx >= self.sz:
            return None
        if idx not in self.vals:
            return None
        return self.vals[idx]

class Arrays:
    def __init__(self):
        self.arrays = {}

    def declare(self, arrName, sz):
        if sz == None:
            return False
        if arrName in self.arrays:
            return False
        self.arrays[arrName] = CustomArray(sz)
        return True

    def assign(self, arrName, idx, val):
        if arrName not in self.arrays:
            return False
        return self.arrays[arrName].assign(idx, val)

    def get(self, arrName, idx):
        if arrName not in self.arrays:
            return None
        return self.arrays[arrName].get(idx)
        
def resolve(expression):
    global arrays

    if "[" not in expression:
        return int(expression)

    arrName = expression[0]
    idx = resolve(expression[2:-1])

    return arrays.get(arrName, idx)

def processAssignment(command):
    global arrays

    equalIdx = command.find("=")
    leftStr = command[:equalIdx]
    rightStr = command[equalIdx + 1:]

    leftArrName = leftStr[0]
    leftIdx = resolve(leftStr[2:-1])
    rhs = resolve(rightStr)
    
    return arrays.assign(leftArrName, leftIdx, rhs)

def processDeclaration(arrStr):
    global arrays
    arrName = arrStr[0]
    sz = int(arrStr[2:-1])
    return arrays.declare(arrName, sz)

if __name__ == '__main__':
    while True:
        commands = []
        while True:
            line = input().strip()
            if line == '.':
                break
            commands.append(line)

        if len(commands) == 0:
            break

        errLine = 0
        arrays = Arrays()

        for i in range(len(commands)):
            command = commands[i]
            
            if "=" in command:
                result = processAssignment(command)
            else:
                result = processDeclaration(command)

            if not result:
                errLine = i + 1
                break

        print(errLine)


Measured memory_bytes: 5848
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;

#define pb push_back
#define int long long
const int N = 1e5+5;
int n, m, u, v;
int color[N];
bool visited[N], congthu = 1;
vector<int> adj[N];

void dfs(int u, int c)
{
    for (auto v: adj[u])
    {
        if(color[v] != -1 && color[v] != c) {
            congthu = 0;
        }
        color[v] = c;
    }
    for (auto v: adj[u])
    {
        if(!visited[v]) {
            visited[v] = 1;
            dfs(v, 1 - c);
        }
    }
}

signed main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    memset(color, -1, sizeof color);
    color[1] = 1;
    visited[1] = 1;
    dfs(1, 0);
    if (!congthu)
        cout << n*(n-1)/2 - m;
    else
    {
        int black = 0, white = 0;
        for (int i = 1; i <= n; i++)
        {
            if (color[i] == 1) black++;
            else if (color[i] == 0) white++;
        }
        cout << black*white-m;
    }
}
/*
6 5
1 2
2 3
3 4
4 5
5 6
*/


Measured memory_bytes: 7680
#include "algorithm"
#include "iostream"
#include "set"
#include "vector"
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  vector<ll> a(N);

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

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

  ll res = 0;

  for (ll i = 0; i < N; i++) {
    for (ll j = i + 1; j < N; j++) {
      ll c = a[i] + a[j];
      auto d = lower_bound(a.begin(), a.end(), c) - a.begin();
      res += d - j - 1;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    N, W = map(int, input().split())
    wv = [
        list(map(int, input().split()))
        for _ in range(N)
    ]

    ans = f(N, W, wv)
    print(ans)


def f(N, W, wv):
    """
    品物100を入れる入れないの 2^100 試せばOKだが、無理

    Nの入れる個数
        0から100
        正確にはN個までの選択なので、N個入れていないときもある
    最終容量     
        0から10^5
        正確にはWまでの重さなので、W以下のときもある
    10^7なら間に合いそう

    追加できるならば、追加してみる
    追加するものと入れ替えを試してみる
        追加の重さを引いたときの価値
        前の価値まま
            の大きい方
    """
    dp = [[-float("inf")] * (W + 1)
          for _ in range(N + 1)]

    # 品物を入れていないならば、価値はない
    # 品物を入れていないならば、重さはないので、価値はない
    # wi, vi >= 1 より
    dp[0] = [0] * (W + 1)
    for i in range(1, N + 1):
        dp[i][0] = 0

    for i, (w, v) in enumerate(wv, 1):
        for _w in range(1, W + 1):
            # まずは1つ前で補完, 価値は品物追加すれば単調増加なのでOK
            bef = dp[i-1][_w]
            dp[i][_w] = bef

            # 追加
            # 品物ループの内側にある重さのループではあるが、
            # このループでは何回も追加しないようになっている
            if _w + w <= W:
                changed = dp[i-1][_w] + v
                bef = dp[i-1][_w + w]
                # 補完と入れ替えを合わせると追加も兼ねている？
                # dp[i][_w + w] = max(bef, changed)

            # 入れ替え
            if _w - w >= 0:
                changed = dp[i-1][_w - w] + v
                bef = dp[i-1][_w]
                dp[i][_w] = max(bef, changed)

    # 補完により必ず[N][W] で最大
    # ans = max(dp[N])
    ans = dp[N][W]

    # from pprint import pprint
    # import sys
    # pprint(dp, stream=sys.stderr)
    return ans


if __name__ == "__main__":
    main()


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

int main(){
    int N;
    cin>>N;
    int a[N];
    rep(i, N){
        cin>>a[i];
    }
    int c[N]={0};
    c[0]=1;
    int b=1;
    int count=0;
    while(true){
        count++;
        if(a[b-1]==2){
            cout<<count<<endl;
            break;
        }
        else{
            if(c[(a[b-1]-1)]==1){
                cout<<-1<<endl;
                break;
            }
            else{
                b=a[b-1];
                c[b-1]=1;
            }
        }
    }
}

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

const int nil = 1000010;
const int MAX = 1010;

char meiro[MAX][MAX];
int cost[MAX][MAX];
int visited[MAX][MAX];

int H, W;

void bfs(int ch, int cw) {
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cost[i][j] = nil;
      visited[i][j] = false;
    }
  }

  deque<pair<int, pair<int, int>>> q;
  q.push_front(make_pair(0, make_pair(ch, cw)));
  cost[ch][cw] = 0;

  while (q.size()) {
    pair<int, pair<int, int>> p = q.front(); q.pop_front();
    pair<int, int> pt = p.second;
    int nowc = p.first;

    if (visited[pt.first][pt.second]) continue;
    else visited[pt.first][pt.second] = true;

    cost[pt.first][pt.second] = nowc;

    for (int h = -2; h < 3; h++) {
      for (int w = -2; w < 3; w++) {
        if (h == 0 && w == 0) continue;

        int nexth = pt.first + h;
        int nextw = pt.second + w;
        if (nexth < 0 || nexth >= H || nextw < 0 || nextw >= W)
          continue;
        if (meiro[nexth][nextw] == '#')
          continue;

        if (visited[nexth][nextw]) continue;

        if (( w == 0 && (h == -1 || h == 1) )
            || ( h == 0 && (w == -1 || w == 1)) ) {
          q.push_front(make_pair(nowc, make_pair(nexth, nextw)));
        } else {
          q.push_back(make_pair(nowc+1, make_pair(nexth, nextw)));
        }
      }
    }
  }

}

int main() {
  cin >> H >> W;

  int ch, cw;
  int dh, dw;
  cin >> ch >> cw;
  cin >> dh >> dw;
  ch--; cw--;
  dh--; dw--;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> meiro[i][j];
    }
  }

  bfs(ch, cw);

  if (cost[dh][dw] != nil) cout << cost[dh][dw] << endl;
  else cout << "-1" << endl;

  return 0;
}



Measured memory_bytes: 12792
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        //3*5*5
        //15*5
        //3*25
        //75
        int n = int.Parse(Console.ReadLine());
        int[] count = new int[n + 1];
        for (int i = 1; i <= n; i++)
        {
            var facs = factors(i);
            foreach (var fac in facs)
            {
                count[fac]++;
            }
        }
        int count2 = 0;
        int count4 = 0;
        int count14 = 0;
        int count24 = 0;
        int count74 = 0;
        foreach (var c in count)
        {
            if (74 <= c) count74++;
            if (24 <= c) count24++;
            if (14 <= c) count14++;
            if (4 <= c) count4++;
            if (2 <= c) count2++;
        }
        Console.WriteLine((count2 - 2) * (count4) * (count4 - 1) / 2 + count14 * (count4 - 1) + count24 * (count2 - 1) + count74);
    }
    static int[] factors(int n)
    {
        int i = 2;
        List<int> res = new List<int>();
        while (i * i <= n)
        {
            if (n % i == 0)
            {
                res.Add(i);
                n /= i;
            }
            else
            {
                i++;
            }
        }
        if (n != 1) res.Add(n);
        return res.ToArray();
    }
}


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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/

int main(){
  int n;
  string s;
  cin >> n >> s;
  
  if(n %2 == 1){
	cout << "No" << endl;
    return 0;
  }
  
  rep(i,n/2){
    if(s[i] != s[i + n/2]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
  

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int a,b;
    cin >> a >> b;
    cout << max(a-b*2,0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int s[100005];
int main(){
	int N,k,q;
	memset(s,0,sizeof(s));
	int a;
	cin >> N >> k >> q;
	for(int i=0;i<q;i++){
		scanf("%d",&a);
		s[a]++;
	}
	for(int i=1;i<=N;i++){
		if(s[i]-q+k>0)printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long inf = 1ll << 62;
typedef long double ld;
typedef pair<ld, int> P;
ld x[105], y[105];

signed main() {
	int n; cin >> n;
	rep(i, n)cin >> x[i] >> y[i];
	vector<P>V;
	rep(i, n) {
		if (x[i] == 0 && y[i] == 0)continue;
		ld theta = atan2(y[i], x[i]);
		V.push_back(P(theta, i));
	}
	sort(V.begin(), V.end());

	ld ans = 0;
	n = V.size();
	rep(i, n) {
		rep(j, n) {
			ld sx = 0, sy = 0;
			if (i<=j) {
				for (int k = i; k <= j; k++) {
					sx += x[V[k].second];
					sy += y[V[k].second];
				}
			}
			else {
				for (int l = i; l <= n + j; l++) {
					int k = l%n;
					sx += x[V[k].second];
					sy += y[V[k].second];
				}
			}
			ld res = sqrt(sx*sx + sy*sy);
			if (ans < res)ans = res;
		}
	}
	printf("%.13Lf\n", ans);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int A,B,a,b,c,d,ans=0;
    cin>>A>>B;
    for(int i=A;i<=B;i++){
        a=i/1000;
        b=a/10;
        c=a%10;
        d=(10*c+b);
        if((i-d)%100==0){
            ans++;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

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

void Main() {
	int N, M; cin >> N >> M;
	vi ss(M, 0);
	REP(i, M) {
		int k; cin >> k;
		REP(j, k) {
			int s; cin >> s;
			--s;
			ss[i] |= (1 << s);
		}
	}
	vi p(M);
	REP(i, M) cin >> p[i];
	int ans = 0;
	for (int bit = 0; bit < (1 << N); ++bit) {
		bool ok = true;
		REP(l, M) {
			int on_cnt = 0;
			for (int i = 0; i < N; ++i) {
				if (bit & (1 << i) && ss[l] & (1 << i)) ++on_cnt;
			}
			if (on_cnt % 2 != p[l]) {
				ok = false;
				break;
			}
		}
		if (ok) ++ans;
	}
	cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
using namespace std;
 
int main(){
  int n,m;
  cin>>n>>m;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  set<int> s;
  for(int i=0; i<m; i++){
    int x,y;
    cin >>x>>y;
    if(a[x-1]>a[y-1]) s.insert(y);
    else if(a[y-1]>a[x-1]) s.insert(x);
    else {
      s.insert(x);
      s.insert(y);
    }
  }
  cout << n-s.size() <<endl;
  return 0;
}

Measured memory_bytes: 6680
n, k = map(int, input().split())
A = list(map(int, input().split()))

# a = []
# tmp = 1
# r = 0
# for l in range(n):
#     tmp *= A[l]
#     if l >= k - 1:
#         a.append(tmp)
#         tmp //= A[r]
#         r += 1

for i in range(k, n):
    if A[i] > A[i - k]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;
typedef priority_queue<int, vector<int>, greater<int>> PQ;
const int MOD = 1000000007;


int main(){

    int N, A, B; cin >> N >> A >> B;
    vector<ll> X(N);
    rep(i,N) cin >> X[i];
    
    ll ans = 0;
    rep(i,N-1){
        ll walk_fatigue = (X[i+1] -X[i])*A;
        if (walk_fatigue < B) ans += walk_fatigue;
        else ans += B;
    }

    cout << ans << endl;


}

Measured memory_bytes: 4056
# coding=utf-8

n = int(raw_input())
cards = {'S':[], 'H':[], 'C':[], 'D':[]}
for _ in xrange(n):
    mark, num = raw_input().split()
    cards[mark].append(num)
for mark in ['S', 'H', 'C', 'D']:
    for i in xrange(1, 14):
        if str(i) not in cards[mark]:
            print mark + ' ' + str(i)

Measured memory_bytes: 4212
import math
from sys import stdin


def get_result(data):
    A, B = data
    min_A, max_A = math.ceil(A / 0.08), math.floor((A+1) / 0.08)
    min_B, max_B = math.ceil(B / 0.10), math.floor((B+1) / 0.10)

    tmp_A = [i for i in range(min_A, max_A)]
    tmp_B = [i for i in range(min_B, max_B)]
    ans = list(set(tmp_A) & set(tmp_B))
    if len(ans) == 0:
        return -1

    return min(ans)


if __name__ == '__main__':
    data = list(map(int, stdin.readline().rstrip('\n').split(' ')))
    result = get_result(data)
    print(result)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
    ld n,m,d;
    cin >> n >> m >> d;
    ld u=(n-d)*2,mm=m-1;
    if(d==0) u=n-d;
    ld ans=mm/n*u/n;
    cout << fixed << setprecision(10) << ans << endl;    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k,i,val,t,p,x,ans=0;
    cin>>n>>k;
    int a[10]={0};
    for(i=0;i<k;i++){cin>>x; a[x]++;}
    for(i=n;i<100000;i++){
        t=i;
        val=0;
        while(t){
            p=t%10;
            if(a[p]!=0){
                val=1;
                break;
            }
            t/=10;
        }
        if(val==1){continue;}
        else {
            ans=i;
            
            break;
        }
        
    }
    cout<<ans;
    
    
    
    
    
   
	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc171/tasks/abc171_e
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<int> v(N);
    int ax = 0;
    for (auto &x : v) {
        cin >> x;
        ax ^= x;
    }
    REP(i, N) { cout << (v[i] ^ ax) << (i == N - 1 ? "\n" : " "); }

    return 0;
}


Measured memory_bytes: 4744