akhauriyash/Code-Regression huggingface dataset:
import sys
import math
import fractions
import bisect
import queue
import heapq
import collections
import itertools
import random
sys.setrecursionlimit(4100000)


D = int(input())
C = list(map(int,input().split()))

S = []
for i in range(D):
    tmp = list(map(int,input().split()))
    S.append(tmp)


class Schejule:

    def __init__(self, sche):
        self.base = sche
        self.last = [0] * 26
        self.y = 0

    def get_score(self):
        self.y = 0
        for d in range(D):
            self.y += S[d][self.base[d]]

        for d in range(D):
            self.last[self.base[d]] = d + 1

            for j in range(26):
                self.y -= C[j] * (d+1 - self.last[j])

    def change_one(self, day, to):

        org = self.base[day]

        # 差分
        div = 0

        # その日の満足度の変化
        div += S[day][to] - S[day][org]

        # 損失
        org_loss = 0
        cha_loss = 0

        org_last = 0
        cha_last = 0
        for d in range(D):
            if self.base[d] == org:
                org_last = d + 1
            elif self.base[d] == to:
                cha_last = d + 1

            org_loss +=  C[org] * (d+1 - org_last)
            cha_loss +=  C[to ] * (d+1 - cha_last)

        def_loss = cha_loss + org_loss


        org_loss = 0
        cha_loss = 0

        org_last = 0
        cha_last = 0
        for d in range(D):
            if d != day:
                if self.base[d] == org:
                    org_last = d + 1
                elif self.base[d] == to:
                    cha_last = d + 1
            else:
                cha_last = d+1

            org_loss +=  C[org] * (d+1 - org_last)
            cha_loss +=  C[to ] * (d+1 - cha_last)

        aft_loss = cha_loss + org_loss


        # 全体の差分
        div -= aft_loss - def_loss

        # ε-greedy
        if div > 0 or random.randint(0, 9) >= 7:
            next_plan = self.base
            next_plan[day] = to

            sche_next = Schejule(next_plan)
            sche_next.y = self.y + div

            return sche_next
        else:
            return self



T = [0] * D

for i in range(D):
    max_day = 0
    for j in range(26):
        if S[i][max_day] < S[i][j]:
            max_day = j
    T[i] = max_day


sche_base = Schejule(T)
sche_base.get_score()


best_score = sche_base.y
best_set = T

#print(sche_base.y)

#print(*sche_base.base)

for i in range(1000):
    d = random.randint(0, D - 1)
    t = random.randint(0, 26 - 1)

    sche_base  = sche_base.change_one(d, t)

    if best_score < sche_base.y:
        best_score = sche_base.y
        best_set = sche_base.base
    #print(*sche_base.base)

    #print(sche_base.y)

for i in range(D):
    print(best_set[i] + 1)


#print(best_score)









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

int main(){
    int H,W,h,w;
    cin >> H >> W >> h >> w;
    cout << H*W - h*W - (H-h)*w<<endl;
}

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

int main() {
  int N,K;
  cin >> N>>K;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
 
  
  

  
  long b=0;
  
  
  for(int i=0; i<K; i++){
    b+=p.at(i); 
  }
  long c=b;
  for(int i=0; i<N-K; i++){
    c=c+p.at(K+i)-p.at(i);
    b=max(b,c); 
  }
  cout << fixed << setprecision(6);
  cout<<(double)(K+b)/2<<endl;
  
  

}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxn=405;
int n;
long long C[maxn][4];
map<long long,int> mp;
inline long long get(int x) {
    return (C[x][0]<<30)|(C[x][1]<<20)|(C[x][2]<<10)|C[x][3];
}
inline long long get(long long a,long long b,long long c,long long d) {
    return (a<<30)|(b<<20)|(c<<10)|d;
}
inline void update(long long x,int y) {
    for (int i=0;i<4;++i) {
        mp[x]+=y;
        x=(x>>10)|((x&1023)<<30);
    }
}
inline bool check(long long a,long long b,long long c,long long d) {
    if (mp.find(a)==mp.end()) return false;
    if (mp.find(b)==mp.end()) return false;
    if (mp.find(c)==mp.end()) return false;
    if (mp.find(d)==mp.end()) return false;
    return true;
}
int main()
{
    scanf("%d",&n);
    for (int i=0;i<n;++i) {
        for (int j=0;j<4;++j) cin>>C[i][j];
        update(get(i),1);
    }
    long long res=0;
    for (int i=0;i<n;++i) {
        update(get(i),-1);
        for (int j=i+1;j<n;++j) {
            update(get(j),-1);
            for (int k=0;k<4;++k) {
                long long a=get(C[i][1],C[i][0],C[j][(1+k)&3],C[j][(  k)&3]);
                long long b=get(C[i][2],C[i][1],C[j][(  k)&3],C[j][(3+k)&3]);
                long long c=get(C[i][0],C[i][3],C[j][(2+k)&3],C[j][(1+k)&3]);
                long long d=get(C[i][3],C[i][2],C[j][(3+k)&3],C[j][(2+k)&3]);
                if (!check(a,b,c,d)) continue;
                long long c1=mp[a];
                update(a,-1);
                long long c2=mp[b];
                update(b,-1);
                long long c3=mp[c];
                update(c,-1);
                long long c4=mp[d];
                if (c1>0&&c2>0&&c3>0&&c4>0) res+=c1*c2*c3*c4;
                update(a,1);
                update(b,1);
                update(c,1);
            }
            update(get(j),1);
        }
        update(get(i),1);
    }
    cout<<res/3<<endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<ll, ll>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

vector<vector<ll>> dp(100, vector<ll>(2, -1));


int main()
{
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  dp[45][0] = 0;


  for(int d = 44; d >= 0; --d) {
    ll mask = 1ll<<d;
    int num = 0;
    rep(i, n) if(a[i] & mask) ++num;
    
    if(dp[d+1][1] >= 0) chmax(dp[d][1], dp[d+1][1] + mask*max(num, n-num));
    if(dp[d+1][0] >= 0) {
      if(k & mask) {
        chmax(dp[d][1], dp[d+1][0]+mask*num);
        chmax(dp[d][0], dp[d+1][0]+mask*(n-num));
      }
      else chmax(dp[d][0], dp[d+1][0]+mask*num);
    }
  }
  cout << max(dp[0][0], dp[0][1]) << endl;
}

Measured memory_bytes: 1024
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

# 入力値を文字列で返却する
def gets_s()
  gets.chomp
end

n, l = gets_i_list
slist = []

n.times do
  slist.push gets_s
end

puts slist.sort.join

Measured memory_bytes: 14576
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main() {
#ifdef _75108D01685041AA959399A981476AD7
  std::freopen("input.txt", "r", stdin);
#endif

  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int a,b;
  cin >> a >> b;
  if (a < b) {
    swap(a, b);
  }
  int sum = 0;
  sum += a--;
  if (a < b) {
    swap(a, b);
  }
  sum += a;
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
#include<algorithm>
using namespace std;
static const int MAX_N = 10;

int main(){
	for(;;){
		int n, k;
		string s[MAX_N];
		set<string> sa;
		cin >> n >> k;
		if(n == 0 && k == 0) break;
		for(int i = 0; i < n; i++) cin >> s[i];
		sort(s, s + n);
		do{
			string t = "";
			for(int i = 0; i < k; i++) t += s[i];
			sa.insert(t);
		}while(next_permutation(s, s + n));
		cout << sa.size() << endl;
	}
	return 0;
}



Measured memory_bytes: 3384
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int N=500010,maxn=500000;
const int mod=998244353;
int inv[N],cj[N];int ans;

int power(int x,int y){
	int ret=1;
	for(;y;y>>=1,x=1ll*x*x%mod){
		if(y&1)	ret=1ll*ret*x%mod;
	}
	return ret;
}

void init(){
	int i;
	cj[0]=1;rep(i,1,maxn)	cj[i]=1ll*cj[i-1]*i%mod;
	inv[maxn]=power(cj[maxn],mod-2);inv[0]=1;
	for(i=maxn-1;i;i--)	inv[i]=1ll*inv[i+1]*(i+1)%mod;
}

inline int C(int n,int m){
	//printf("%d %d\n",n,m);
	if(m<0||n<m)	return 0;
	return 1ll*cj[n]*inv[m]%mod*inv[n-m]%mod;
}

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int i,n,m;
	init();
	scanf("%d%d",&n,&m);
	rep(i,0,min(m/2-(m+1&1),m-n)){
		ans=(1ll*ans+C(m,i)-C(m,i-(m-i-n+1)))%mod;
		//if(2*i==m)	ans=(1ll*ans-(C(m-1,i-(m-i-n))-C(m-1,i-(m-i-n+1))))%mod;
		//printf("%d\n",ans);
	}
	i=m/2;
	if(2*i==m&&i<=m-n)	ans=(1ll*ans+C(m-1,i-1)-C(m-1,i-1-(m-i-n+1)))%mod;
	ans=(ans%mod+mod)%mod;
	printf("%d",ans);
}
	

Measured memory_bytes: 4224
N = int(input())
V = list(map(int,input().split()))
C = list(map(int,input().split()))

sumX = 0
sumC = 0

for i in range(N):
    if (V[i] - C[i]) > 0 :
        sumX += V[i]
        sumC += C[i]

print(sumX - sumC)

Measured memory_bytes: 38256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC100_C solver = new ABC100_C();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC100_C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();

            long ans = 0;
            for (int i = 0; i < n; i++) {
                long a = in.nextLong();

                while (a % 2 == 0) {
                    ans++;
                    a /= 2;
                }
            }
            out.print(ans);
        }

    }
}



Measured memory_bytes: 34044
//temprates
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

using ll = long long;
using namespace std;

#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define LFOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define FORR(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define LFORR(i,a,b) for(ll i = (int)(a); i >= (ll)(b); i--)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define LREP(i,n) LFOR(i,0,(ll)(n)-1)
#define REPR(i,n) FORR(i,(int)(n)-1,0)
#define LREPR(i,n) LFORR(i,(ll)(n)-1,0)

#define SIZ(v) int(v.size())
const int INF = 1e8;
const ll LINF = 1e15;
const int MOD = 1e9+7;




int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
int l,n;
cin >> n >> l;
if(l>=0) cout << l*(n-1)+(n*(n-1))/2 << endl;
else if(l<0&&l+n-1>=0)
  cout << l*n+((n-1)*(n))/2 << endl;
else cout << l*(n-1)+((n-2)*(n-1))/2 << endl;

}


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

using namespace std;
const int maxn = 1e5 + 1000;
const int mod = 1e9 + 7;
long long s[maxn], t[maxn];
long long ans1 = 0, ans2 = 0;

long long fun(long long a, long long n) {
    long long sum = 0;
    sum = (n - a) * a % mod;
    return sum;
}

int main() {
    long long n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        cin >> s[i];
    }
    for (int i = 1; i <= m; i++) {
        cin >> t[i];
    }
    for (int i = 1; i + 1 <= n; i++) {
        if (i == 1 || i + 1 == n) {
            ans1 = (ans1 + ((s[i + 1] - s[i]) % mod) * (n - 1)) % mod;
        } else {
            ans1 = (ans1 + ((s[i + 1] - s[i]) % mod) * fun(i, n)) % mod;
        }
    }
    for (int i = 1; i + 1 <= m; i++) {
        if (i == 1 || i + 1 == m) {
            ans2 = (ans2 + ((t[i + 1] - t[i]) % mod) * (m - 1)) % mod;
        } else {
            ans2 = (ans2 + ((t[i + 1] - t[i]) % mod) * fun(i, m)) % mod;
        }
    }
    cout << (ans1 * ans2) % mod << endl;
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
s = [input() for _ in range(N)]
words_sort = ""

#Dictionaly
dic = {}

for i in range(N):
    words_sort = ''.join(sorted(s[i]))
    if (words_sort in dic) == True:
        dic[words_sort] += 1
    else:
        dic[words_sort] = 1

ans = 0
for v in dic.values():
    ans += v*(v-1)//2

print(ans)

Measured memory_bytes: 24976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int n;
    cin >> n;
    vl a(n);
    rep(i, n) cin >> a[i];
    multiset<ll> st;
    rep(i, n) st.insert(-a[i]);
    int ans = 0;
    while(!st.empty()) {
        auto it = st.begin();
        ll x = -(*it);
        st.erase(it);
        repr(i, 32) {
            ll sum = 1LL << i;
            ll rest = sum - x;
            if(st.count(-rest)) {
                auto it2 = st.lower_bound(-rest);
                st.erase(it2);
                ++ans;
                break;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 11136
n_max = 1012500
hs = []
rec = lambda do |x, i|
  break unless x <= n_max
  hs << x
  while i < 3
    rec[x * [2, 3, 5][i], i]
    i += 1
  end
end
rec[1, 0]
hs.sort!
loop do
  m, n = gets.split.map(&:to_i)
  break if m.zero?
  i, j = [m, n+1].map do |x|
    hs.find_index {|h| x <= h }
  end
  p j - i
end

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

int main()
{
	int n;
	cin >> n;
	int scores[n];
	int sum = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> scores[i];
		sum += scores[i];
	}	

	sort(scores, scores + n);
	if (sum % 10 == 0)
	for (int i = 0; i < n; ++i)
	{
		if (scores[i] % 10 != 0) 
		{
			sum -= scores[i];
			break;
		}
	}

	if (sum % 10 == 0) cout << 0;
	else cout << sum;



	return 0;
}

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

/* define*/
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( i = a; i < b ; i++)
#define REP(i, n) for ( i = 0; i < n ; i++)
#define DER(i, n) for ( i = n; n ; i--)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1e9 + 7;

/* alias */
typedef long long ll;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

/* main */
int i, j, k;

int main() {
	int w;
	char s[1001];
	scanf("%s %d", s, &w);
	for (i = 0; i < strlen(s); i += w)printf("%c", s[i]);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  string s, op = "+-";
  cin >> s;
  int a[4];
  rep(i, 4) a[i] = s[i] - '0';
  rep(i, 2) {
    rep(j, 2) {
      rep(k, 2) {
        int sum = a[0];
        if (i == 0)
          sum = sum + a[1];
        else
          sum = sum - a[1];
        if (j == 0)
          sum = sum + a[2];
        else
          sum = sum - a[2];
        if (k == 0)
          sum = sum + a[3];
        else
          sum = sum - a[3];
        if (sum == 7) {
          cout << a[0] << op[i] << a[1] << op[j] << a[2] << op[k] << a[3]
               << "=7" << endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
#define EPS 1e-10
#define equals(a,b) (fabs((a)-(b)) < EPS)
//???
class Point{
	public:	
		double x,y;
		Point(double x = 0,double y = 0):x(x),y(y){}
		//?????????
		Point operator + (Point p) { return Point(x + p.x,y + p.y);}
		Point operator - (Point p) { return Point(x - p.x,y - p.y);}
		Point operator * (double a) { return Point(x*a,y*a);}
		Point operator / (double a) { return Point(x/a,y/a);}
		//???????????¨??§??????
		double abs() {return sqrt(norm());}
		double norm() {return x*x+y*y;}

		bool operator < (const Point &p) const{
			return x != p.x ? x < p.x : y < p.y;
		}
		bool operator == (const Point &p) const{
			return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
		}
};
//??????
struct Segment{Point p1,p2;};
//????????????
typedef Point Vector;
//??´???
typedef Segment Line;
//???
class Circle{
	public:
		Point c;
		double r;
		Circle(Point c = Point(),double r = 0.0): c(c),r(r){}
};
//????§???¢
//typedef Vector<Point> Polygon;
//????????¨??????
double dot(Vector a,Vector b){
	return a.x*b.x + a.y*b.y;
}
double cross(Vector a,Vector b){
	return a.x*b.y - a.y*b.x;
}

Point projection(Segment a,Vector hypo){
	Vector base = a.p2 - a.p1;
	double r = dot(hypo,base)/base.norm();
	return  a.p1 + base*r;
}

int main(){
	int x0,y0,x1,y1;
	int n;
	int x2,y2;
	cin >> x0 >> y0 >> x1 >> y1;
	cin >> n;
	Point s(x0,y0);
	Point t(x1,y1);
	Segment seg;seg.p1 = s;seg.p2 = t;
	Vector base(t.x-s.x,t.y-s.y);
	for(int i = 0;i < n;i++){
		cin >> x2 >> y2;
		Point a(x2,y2);
		Vector hypo(x2-x0,y2-y0);
		Point p = projection(seg,hypo);
		Vector v4(p.x-x2,p.y-y2);
		double v4dis = v4.abs();
		Point ans = a + v4 * 2.0;
		printf("%.10f %.10f",ans.x,ans.y);
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
import sys

N = int(input())
button = [0]*N

for i in range(N):
    button[i] = int(input())-1
count, now = 0, 0

while count <= N:
    now = button[now]
    count += 1
    if now == 1:
        print(count)
        sys.exit()
print(-1)


Measured memory_bytes: 12844
# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline

x,y = map(int,read().split())

if abs(x-y) <= 1:
    print("Brown")
else:
    print("Alice")


"""
n = 10
dp = [[0]*n for _ in range(n)]
dp[0][0] = dp[0][1] = dp[1][0] = dp[1][1] = 2

for i in range(n):
    for j in range(i+1):
        I = i-j
        J = j
        assert I >= 0 and J >= 0
        if dp[I][J] != 0: continue

        for k in range(1,I//2+1):
            if dp[I-2*k][J+k]==2: dp[I][J] = 1
        for k in range(1,J//2+1):
            if dp[I+k][J-2*k]==2: dp[I][J] = 1
        if dp[I][J] == 0:
            dp[I][J] = 2
            

for i in dp:
    print(i)
"""



Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
struct
{
    int x, y, h;
} a[105];
int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].h);
    for (int i = 0; i < n && a->h == 0; i++)
        if (a[i].h)
            iter_swap(a + i, a);
    for (int i = 0; i <= 100; i++)
        for (int j = 0; j <= 100; j++)
        {
            int pre = a->h + abs(i - a->x) + abs(j - a->y);
            bool flag = true;
            for (int k = 0; k < n && flag; k++)
                if (max(pre - abs(i - a[k].x) - abs(j - a[k].y), 0) != a[k].h)
                    flag = false;
            if (flag)
                return printf("%d %d %d", i, j, pre), 0;
        }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <fstream>
#include <queue>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <time.h>
#include <list>

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define chk(a) rep(i, a.size()) cout << a[i] << " "
#define SORT(c) sort((c).begin(),(c).end())
#define ll long long
#define vi(m,a) vector<int> m(a)
#define vti(m,a,i) vector<vector<int>> m(a,vector<int>(i))
#define ALL(it,a) for(auto it = a.begin(); it!=a.end(); it++)
#define Fe(it,a) for(auto &it : a)
#define all(a) begin(a),end(a)


using namespace std;
typedef pair<int, int> pii;

int main(void) {

	ll n, x;
	cin >> n >> x;
	ll result = 0;

	if (x > n / 2) {
		x = n - x;
	}

	while (x != 0) {
		ll tmp = x;
		result += (n / x - 1) * 3 * x;
		n = (n - x * (n / x - 1));
		x = n % tmp;
	}
	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll n;
char a[10];
void dep(ll now,ll cnt){
	if(now==n){
		for(ll i=0;i<n;i++){
			cout << a[i];
		}
		cout <<endl;
		return ;
	}
	for(ll i=0;i<cnt;i++){
		a[now]='a'+i;
		if(i==cnt-1){
			dep(now+1,cnt+1);
		}
		else{
		dep(now+1,cnt);
		}
	}
}
int main() {
	cin>>n;
	dep(0,1);
	return 0;
}

Measured memory_bytes: 1536
import sys
import numpy as np

n, m = map(int, sys.stdin.readline().split())
A = np.array([list(sys.stdin.readline().rstrip()) for _ in range(n)], dtype='U1')
B = np.array([list(sys.stdin.readline().rstrip()) for _ in range(m)], dtype='U1')

def main():
    
    for i in range(n - m + 1):
        for j in range(n - m + 1):
            if np.all(A[i:i+m, j:j+m] == B):
                return 'Yes'
    return 'No'

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 12516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  bool used[n];
  rep(i,n) used[i]=false;
  int ind=n-1;
  int pw=30;
  int ans=0;
  int sp=-100;
  int jp=-100;
  while(ind>=0){
    if(used[ind]){
      ind--;
      continue;
    }
    while(a[ind]/((int)pow(2,pw))==0){
      pw--;
    }
    int k=a[ind]-pow(2,pw);
    int e=upper_bound(a,a+n,pow(2,pw)-k) - a;
    int s=lower_bound(a,a+n,pow(2,pw)-k) - a;
    int st=s;
    if(s==sp && a[s]==pow(2,pw)-k){
      if(used[ind+1] && a[ind+1]==pow(2,pw)+k){
	    s=jp+1;
      }
    }  
    sp=st;
    for(int j=s;j<e;j++){
      if(!used[j]){
	if(j!=ind){
	  ans++;
	  used[ind]=true;
	  used[j]=true;
	  jp=j;
	  break;
	}
      }
    }
    //    if(!used[ind]) jp=-1;
    ind--;
  }
  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
    private static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int x=sc.nextInt();
        int y=sc.nextInt();
        while(y>0){
            int t=x%y;
            x=y;
            y=t;
        }
        System.out.println(x);
    }
}

Measured memory_bytes: 26084
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int k; cin >> k;
    vector<ll> a; 
    for(int i=1; i <= 9; ++i) a.pb(i);
    while(true){
        if(k <= a.size()){
            cout << a[k-1] << endl;
            return 0;
        }
        k -= a.size();
        vector<ll> old;
        swap(old,a);
        for(ll x : old){
            for(int i = -1; i <= 1; i++){
                int d = x % 10 + i;
                if(d < 0 || d > 9) continue;
                ll nx = x * 10 + d;
                a.pb(nx);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1712
// https://atcoder.jp/contests/abc048/tasks/abc048_b

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
  /* Magic word */
  cin.tie(0);
  ios::sync_with_stdio(false);
  /* ---------- */

  long long a, b, x;

  cin >> a >> b >> x;

  cout << max(0ll, ((b - b % x + x) - a) / x) << '\n';

  return 0;
}


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

int main(){
	int i,n, m, x, y;
	cin >> n >> m >> x >> y;
	vector<int> a(n);
	vector<int> b(m);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (i = 0; i < m; i++) {
		cin >> b[i];
	}
	string ans = "War";
	int maxa = *max_element(a.begin(), a.end());
	int minb = *min_element(b.begin(), b.end());
	for (i = x + 1; i <= y; i++) {
		if (maxa < i&&minb >= i) {
			ans = "No War";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
let n = Int(readLine()!)!
var dic = [Character: [Int]]()
"abcdefghijklmnopqrstuvwxyz".characters.forEach{dic[$0]=(0..<n).map{_ in 0}}
for i in 0..<n {
    for c in readLine()!.characters {
        dic[c]![i] += 1
    }
}
print(dic.sort{$0.0<$1.0}.reduce(""){S,d in S+(0..<d.1.minElement()!).reduce(""){s,_ in s+"\(d.0)"}})

Measured memory_bytes: 2816
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),a.end()
using namespace std;

int main()
{
	int n,x;
	cin >> n;
	cin >> x;
	int min = 1000;
	vector <int> m;
	rep(i, n) {
		int tmp;
		cin >> tmp;
		if (tmp < min)min = tmp;
		m.push_back(tmp);
		x -= tmp;
	}
	cout << n + (x / min) << endl;

}



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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    int n, l;
    cin >> n >> l;

    vector<string> strings;

    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        strings.push_back(s);
    }

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

    string wholestring = "";

    for(int i = 0; i < n; i++){
        wholestring = wholestring + strings[i];
    }

    cout << wholestring;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a[101000];
    long long k,m,n;
    cin>>a;
    n=strlen(a);
    for(int i=0;i<n;i++)
    {
        if(a[i]=='e')      
        {
            if(a[i+1]=='r'&&a[i+2]=='a'&&a[i+3]=='s'&&a[i+4]=='e')      
            {
                if(a[i+5]=='r')      
                {
                    i+=5;
                }
                else          
                {
                    i+=4;
                }
            }
        }
        else if(a[i]=='d')      
        {
            if(a[i+1]=='r'&&a[i+2]=='e'&&a[i+3]=='a'&&a[i+4]=='m') 
            {
                if(a[i+5]=='e'&&a[i+6]=='r'&&a[i+7]=='a'&&a[i+8]=='s'&&a[i+9]=='e')      
                {
                    i+=4;
                }
                else
                {
                    if(a[i+5]=='e'&&a[i+6]=='r')    
                    {
                        i+=6;
                    }
                    else
                    {
                        i+=4;
                    }
                }
            }
        }
        else 
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;   
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(a: int, b: int):
    return (a - 1) + (1 if a <= b else 0)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    result = solve(a, b)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5884
def ceil_div(x, y):
    return (x + y - 1) // y

n = int(input())
ans = 1
tt = 1
aa = 1
for i in range(n):
    t, a = map(int, input().split())
    x = t + a
    p = max(ceil_div(ans, x), ceil_div(tt, t), ceil_div(aa, a))
    ans = x * p
    aa = a * p
    tt = t * p
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <iomanip>

using ll = long long;

using namespace std;

using P = pair<double, double>;

int main() {
    int n;
    cin >> n;
    P en[n];
    for (auto &ei:en) cin >> ei.first >> ei.second;
    double best = 0;
    for (int i=0; i<100; i++) {
        double theta = 2 * M_PI * i / 100;
        double x = cos(theta), y = sin(theta);
        P sum = {0, 0};
        for (auto &ei:en)
            if (x * ei.first + y * ei.second > 0) {
                sum.first += ei.first;
                sum.second += ei.second;
            }
        best = max(best, hypot(sum.first, sum.second));
    }
    cout << setprecision(15) << best << '\n';
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>

#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

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

int main(void) {

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

  int e = 1 << n, ans = INT_MAX;
  rep(f, e) {
    int u[20] = {}, cost = 0;
    rep(i, n) {
      if ((f >> i) & 1) {
	cost += c[i];
	rep(j, m) u[j] += a[i][j];
      }
    }
    bool q = true;
    rep(i, m) {
      if (u[i] < x) q = false;
    }
    if (q) ans = min(ans, cost);
  }
  if (ans == INT_MAX) ans = -1;
  cout << ans << endl;
}
    


Measured memory_bytes: 3592
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BHinaArare {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int n;
	    map<char, int> cnt;
	    char inc;
	    in >> n;
	    for(int i=0; i<n; i++){
	        in >> inc;
	        cnt[inc]++;
	    }

	    if(cnt.size() == 3) out << "Three" << endl;
	    else out << "Four" << endl;
	}
};


int main() {
	BHinaArare solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
###############################################################################

from bisect import bisect_left as binl

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


###############################################################################


def main():
    n = intin()
    capalist = intinl(5)

    time = n // min(capalist) + (1 if n % min(capalist) else 0)
    print(time + 4)


if __name__ == '__main__':
    main()


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

signed main(){
    string s;
    cin >> s;
    int n = s.size();
    int num[n], r[n];
    rep(i,n){
        num[i] = s[i] - '0';
        r[i] = 10 - num[i];
    }
    vector<vector<int>> dp(n + 1, vector<int>(2, 0));
    dp[0][1] = INF;
    for(int i = 0; i < n; i++){
        dp[i + 1][0] = min(dp[i][0] + num[i], dp[i][1] + num[i]);
        dp[i + 1][1] = min(dp[i][0] + 1 + r[i], dp[i][1] + r[i] - 1);
    }
    cout << min(dp[n][0], dp[n][1]) << endl;
    return 0;
}

Measured memory_bytes: 63748
#include<bits/stdc++.h>
#define ll long long
#define nes ios_base :: sync_with_stdio(0); cin.tie(0);
ll mod=1000000007;
using namespace std;
int main(){
	nes;
	string s,t;
	cin>>s>>t;
	int res=t.size();
	for(int i=0;i<=s.size()-t.size();++i){
		int count=0,l=i;
		for(int j=0;j<t.size();++j){
			if(t[j]!=s[l+j]) ++count;
		}
		res=min(res,count);
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 3656
n=int(input())
if n==3:
  print(61)
  exit()
mod=pow(10,9)+7
#d={'A':0,'G':1,'C':2,'T':3}
d={0:'A',1:'G',2:'C',3:'T'}
dd={}
dinitial={}
for i in range(4**4):
  key=[]
  for _ in range(4):
    key.append(d[i%4])
    i//=4
  key=''.join(key)
  if 'AGC' in key:continue
  if 'ACG' in key:continue
  if 'GAC' in key:continue
  if key[0]=='A' and key[2:4]=='GC':continue
  if key[0:2]=='AG' and key[3]=='C':continue
  dd[key]=1
  dinitial[key]=0

for _ in range(n-4):
  ddd=dinitial.copy()
  for k in dd:
    if k[1:]+'A' in ddd:
      ddd[k[1:]+'A']+=dd[k]
      ddd[k[1:]+'A']%=mod
    if k[1:]+'G' in ddd:
      ddd[k[1:]+'G']+=dd[k]
      ddd[k[1:]+'G']%=mod
    if k[1:]+'C' in ddd:
      ddd[k[1:]+'C']+=dd[k]
      ddd[k[1:]+'C']%=mod
    if k[1:]+'T' in ddd:
      ddd[k[1:]+'T']+=dd[k]
      ddd[k[1:]+'T']%=mod
  dd=ddd

print(sum(dd.values())%mod)


Measured memory_bytes: 9304
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define MAX (1000000000+7)
int main(int argc, char*argv[])
{
	int N;
	cin >> N;
	vector<double> p(N);
	vector<vector<double>> dp(N+1, vector<double>(N+1));
	for (int i=0; i<N; i++)
	{
		static double prev = 1;
		cin >> p[i];
		dp[i+1][0] = prev * (1-p[i]);
		prev  = dp[i+1][0];
	}
	/*
	dp table has coins in rows and # of heads as colums , column #0 is tails , which is calculated above
	For example : 2 coins with 1 head =  2nd coin is tails * 1st coins is head + 2nd coin is head * 1st coin is tail.
	
	*/
	for (int i = 1; i <= N; i++)
		for (int j = 1; j <= i; j++)
		{
			if(i==j)
				dp[i][j] = i==1? p[i-1]:  p[i-1] * dp[i-1][j-1];
			else
				dp[i][j] = (1-p[i-1])*(dp[i-1][j])+(p[i-1]*dp[i-1][j-1]) ; 
		}
	int count = (N>>1) +1;
	double res = 0;
	for (int i=count ; i<=N; i++)
		res += dp[N][i];
	printf("%.10lf", res);
}

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

int main()
{
  long long n, k;
  cin >> n >> k;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) {
    cin >> v.at(i);
  }

  unordered_map<long long, long long> cnt;
  vector<long long> psum(n+1);
  for (long long i = 0; i < n; i++) {
    psum.at(i+1) = psum.at(i) + v.at(i);
  }
  long long res = 0;
  for (long long i = 0; i < (long long)psum.size(); i++) {
    if (k <= i) {
      cnt[(psum.at(i-k) - i + k) % k]--;
    }
    res += cnt[(psum.at(i) - i) % k]++;
  }
  /*
  long long res = 0;
  for (const auto& p : cnt) {
    res += p.second * (p.second - 1) / 2;
  }
  */
  cout << res << '\n';

  return 0;
}


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

template <int MOD> struct modnum {
	static_assert(MOD > 0, "MOD must be positive");

private:
	using ll = long long;

	int v;

	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}

public:

	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }

	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }

	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}

	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}

	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};

using num = modnum<int(1e9)+7>;

const int MAXN = 6000;
int N;
vector<int> adj[MAXN];
int sz[MAXN];
num dp[MAXN][MAXN];

num tmp[MAXN];

void dfs(int cur, int prv = -1) {
	sz[cur] = 1;
	dp[cur][1] ++;
	for (int nxt : adj[cur]) {
		if (nxt == prv) continue;
		dfs(nxt, cur);
		for (int i = sz[cur] + sz[nxt]; i > 0; i -= 2) {
			tmp[i] = 0;
		}
		for (int i = sz[cur]; i > 0; i -= 2) {
			for (int j = sz[nxt]; j >= 0; j -= 2) {
				tmp[i+j] += dp[cur][i] * dp[nxt][j];
			}
		}
		sz[cur] += sz[nxt];
		for (int i = sz[cur]; i > 0; i -= 2) {
			dp[cur][i] = tmp[i];
		}
	}
	if (sz[cur] % 2 == 0) {
		num fac = -1;
		dp[cur][0] = 0;
		for (int i = 2; i <= sz[cur]; i += 2) {
			fac *= num(i-1);
			dp[cur][0] += fac * dp[cur][i];
		}
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> N;
	for (int i = 0; i < N-1; i++) {
		int x, y; cin >> x >> y;
		x--, y--;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	dfs(0);
	assert(N % 2 == 0);
	assert(sz[0] == N);
	cout << -dp[0][0] <<'\n';

	return 0;
}


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

int main()
{
	int ch[26];
	for(int i = 0; i < 26; ++i)
	{
		ch[i] = 0;
	}
	
	string str;
	while(getline(cin, str))
	{
		for(int i = 0; i < str.length(); ++i)
		{
			if('A' <= str[i] && str[i] <= 'Z')
			{
				str[i] = str[i] - 'A' + 'a';
			}
			
			if('a' <= str[i] && str[i] <= 'z')
			{
				++ch[str[i] - 'a'];
			}
		}
	}
	for(int i = 0; i < 26; ++i)
	{
		cout << (char)('a' + i) << " : " << ch[i] << endl;
	}

    return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
const ll INF = 1LL<<60;




int main()
{
    int N;
    cin >> N;
    ll ans = 1;
    bool ng = false;
    bool zero = false;
    rep(i,N){
        ll A;
        cin >> A;
        if(A == 0 || ans == 0){
            zero = true;
            continue;
        }
        if(1000000000000000000LL/ans < A){
            ng = true;
            continue;
        }
        if(i == 0) ans = A;
        else ans *= A;
    }

    if(ng) ans = -1;
    if(zero) ans = 0;

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define print(X) cout << (X) << "\n"
#define _ << " " <<
static const int INF = 1e+9+7;


int main(){
  ll N;
  cin >> N;
  string s;
  map<string, ll> m;
  char next;
  rep(i,0,N){
    cin >> s;
    if(i > 0){
      if(next == s[0]) m[s]++;
    } else {
      m[s]++;
    }
    next = s[s.size()-1];
  }
  // print(m.size());

  if(m.size() == N) print("Yes");
  else print("No");

  return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <string>
#include <cstring>
#include <complex>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = 3030;
int n;
int a[N];
vector<int> g[N];

bool solve(int v, int p)
{
    bool res = p != -1 && a[v] >= a[p];
    for (int u : g[v])
    {
        if (u == p) continue;
        res |= !solve(u, v);
    }
    return res;
}

int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    for (int i = 1; i < n; i++)
    {
        int v, u;
        scanf("%d%d", &v, &u);
        v--;u--;
        g[v].push_back(u);
        g[u].push_back(v);
    }
    for (int i = 0; i < n; i++)
        if (solve(i, -1))
            printf("%d ", i + 1);
    printf("\n");

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    char d[ 4 ][ 8 ];

    scanf ( " %s", d[ 0 ] );
    if ( d[ 0 ][ 0 ] == '0' )  break ;
    scanf ( " %s", d[ 1 ] );
    scanf ( " %s", d[ 2 ] );

    if ( d[ 0 ][ 0 ] != '+'
      && ( ( d[ 0 ][ 0 ] == d[ 0 ][ 1 ] && d[ 0 ][ 0 ] == d[ 0 ][ 2 ] )
        || ( d[ 0 ][ 0 ] == d[ 1 ][ 0 ] && d[ 0 ][ 0 ] == d[ 2 ][ 0 ] ) ) )
    {
      printf ( "%c\n", d[ 0 ][ 0 ] );
    }
    else if ( d[ 2 ][ 2 ] != '+'
      && ( ( d[ 2 ][ 2 ] == d[ 2 ][ 1 ] && d[ 2 ][ 2 ] == d[ 2 ][ 0 ] )
        || ( d[ 2 ][ 2 ] == d[ 1 ][ 2 ] && d[ 2 ][ 2 ] == d[ 0 ][ 2 ] ) ) )
    {
      printf ( "%c\n", d[ 2 ][ 2 ] );
    }
    else if ( d[ 1 ][ 1 ] != '+'
           && ( ( d[ 1 ][ 1 ] == d[ 1 ][ 0 ] && d[ 1 ][ 1 ] == d[ 1 ][ 2 ] )
             || ( d[ 1 ][ 1 ] == d[ 0 ][ 1 ] && d[ 1 ][ 1 ] == d[ 2 ][ 1 ] )
             || ( d[ 1 ][ 1 ] == d[ 0 ][ 0 ] && d[ 1 ][ 1 ] == d[ 2 ][ 2 ] )
             || ( d[ 1 ][ 1 ] == d[ 0 ][ 2 ] && d[ 1 ][ 1 ] == d[ 2 ][ 0 ] ) ) )
    {
      printf ( "%c\n", d[ 1 ][ 1 ] );
    }
    else
    {
      puts ( "NA" );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  ll x;
  cin >> x;
  ll shoki = 100;
  ll ans = 0;
  while(shoki < x){
    shoki += shoki / 100;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3640
import itertools as it, bisect as bs
f=lambda:map(int,input().split())
g=lambda:[0]+[*it.accumulate(f())]
n,m,k=f()
A,B=g(),g()
a,j=0,m
for i in range(n+1):
  t=bs.bisect(B,k-A[i])
  if t: a=max(a,i+t-1)
print(a)

Measured memory_bytes: 48444