akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fo(i,a,n) for(i=a;i<n;i++)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define sortrev(x) sort(all(x),greater<int>())
#define pi 3.1415926535897932384626

typedef pair<int,int> pii;
typedef pair<ll, ll> pl;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pl>	vpl;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;
typedef vector<double> vd;


const int mod = 100000007;
const int inf = 100000005;
const int N = 200005, M = N;
int i,j,n,m;

ll cnt , idx;
vi temp;



void solve() {
   string s;
   cin>>s;
   if(s == "Sunny") cout<<"Cloudy\n";
   else if(s == "Cloudy") cout<<"Rainy\n";
   else cout<<"Sunny\n";
}

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

    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}




Measured memory_bytes: 3516
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;

int main(){
  ll N,u,v,ans=0;
  cin >> N >> u >> v;
  u--;
  v--;
  vector<vector<ll>> A(N,vector<ll>(0));
  vector<ll> d(N,-1),p(N,-1);
  queue<ll> Q;
  rep(i,N-1){
    ll a,b;
    cin >> a >> b;
    A.at(a-1).push_back(b-1);
    A.at(b-1).push_back(a-1);
  }
  Q.push(u);
  d.at(u)=0;
  while(!Q.empty()){
    ll q=Q.front();
    Q.pop();
    rep(i,A.at(q).size()){
      if(d.at(A.at(q).at(i))==-1){
        d.at(A.at(q).at(i))=d.at(q)+1;
        Q.push(A.at(q).at(i));
      }
    }
  }
  Q.push(v);
  p.at(v)=0;
  while(!Q.empty()){
    ll q=Q.front();
    Q.pop();
    rep(i,A.at(q).size()){
      if(p.at(A.at(q).at(i))==-1){
        p.at(A.at(q).at(i))=p.at(q)+1;
        Q.push(A.at(q).at(i));
      }
    }
  }   
  rep(i,N){
    if(d.at(i)<p.at(i)){
      ans=max(p.at(i)-1,ans);
    }
  }
  cout << ans << endl;
    
  
}

Measured memory_bytes: 8064
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int N=5001;
int dp[N][N];
char s[N];
int32_t main()
{
  #ifndef ONLINE_JUDGE
    freopen("in","r",stdin);
    freopen("out","w",stdout);
  #endif
  int n;
  cin>>n>>s;

  //dp[i][j] is longest length of prefix starting at i and j that is equal
 int ans=0;
  for(int i=n-1;i>=0;i--)
    for(int j=i;j>=0;j--)
    {
     
      if(s[i]==s[j]){dp[i][j]=dp[i+1][j+1]+1;}
      if(i-j>=dp[i][j])ans=max(ans,dp[i][j]);
      
     // cout<<i<<' '<<j<<" : "<<dp[i][j]<<"\n";
    }

    cout<<ans;

  

  
 

}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
	

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,i;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
    {
    	cin>>arr[i];
    }
    ll dp[n];
    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);
    for(i=2;i<n;i++)
    {
    	dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n;
    cin >> n;
    cout << (n >= 30 ? "Yes" : "No") << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

ll n;
vector<ll> a(3), l, g;
ll ans = 1e18;

void calc() {
  ll cost = 0;
  REP(i, 3) {
    ll sum = 0, sz = 0;
    REP(j, n) {
      if (g[j] != i) {
        continue;
      }
      sz++;
      sum += l[j];
    }
    if (sz == 0) {
      return;
    }
    cost += 10 * (sz - 1) + abs(sum - a[i]);
  }
  ans = min(ans, cost);
}

void dfs() {
  if (SZ(g) == n) {
    calc();
    return;
  }

  REP(i, 4) {
    g.push_back(i);
    dfs();
    g.pop_back();
  }
}

int main() {
  cin >> n;
  l = vector<ll>(n);
  REP(i, 3) { cin >> a[i]; }
  REP(i, n) { cin >> l[i]; }
  dfs();
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<set>
#define LL long long
#define INF 1000000009
#define maxn 10000009
#include <set>
#include<iostream>
#include<algorithm>
#include<map>
#include<cmath>
#include<vector>
using namespace std;
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
int main()
{
    int n,k,a[100001],maxi=0;
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        maxi=max(a[i],maxi);
    }
    if(k>maxi)
    {
        printf("IMPOSSIBLE\n");
    }
    else
    {
        int kk=a[0];
        for(int i=1;i<n;i++)
        {
            kk=gcd(kk,a[i]);
        }
        //printf("%d\n",kk);
        if(k%kk==0)
        {
            printf("POSSIBLE\n");
        }
        else
        {
            printf("IMPOSSIBLE\n");
        }
    }
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1e18 + 10;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int ketawa(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n/=10;
    }
    return res;
}

int main(){ 
    int n, a, b; cin >> n >> a >> b;
    int res = 0;
    rept(i, 1, n+1){
        int sum = ketawa(i);
        if(sum >= a && sum <= b)res += i;
    }
    cout << res << ln;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] != L[j] != L[k]:
                if L[i] + L[j] > L[k]:
                    ans += 1

print(ans)


Measured memory_bytes: 9112
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef long long ll;

int main() {
    int H, W, n;
    cin >> H >> W;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];


    vector<vector<int>> v;
    v = vector<vector<int>>(H, vector<int>(W, 0));

    int idx_x=0, idx_y=0;
    for(int i=0;i<n;i++) {
        for(int j=0;j<a[i];j++) {
            if(idx_y%2==0) {
                v[idx_y][idx_x] = i + 1;
                if(idx_x == W-1) {
                    idx_y++;
                } else {
                    idx_x++;
                }
            } else {
                v[idx_y][idx_x] = i+1;
                if(idx_x == 0) {
                    idx_y++;
                } else {
                    idx_x--;
                }
            }
        }
    }

    for(int i=0;i< H;i++) {
        for(int j=0;j<W;j++) {
            if(j != W-1)
                cout << v[i][j] << " ";
            else
                cout << v[i][j]<< endl;
        }
    }


}


Measured memory_bytes: 384
// 解説見ました
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;

int main() {
	int X, Y, Z, K;

	scanf("%d %d %d %d", &X, &Y, &Z, &K)+1;

	ll tmp;
	vector<ll> A, B, C;
	A.reserve(X);
	B.reserve(Y);
	C.reserve(Z);
	for (int i = 0; i < X; i++) {
		scanf("%lld", &tmp)+1;
		A.push_back(tmp);
	}
	for (int i = 0; i < Y; i++) {
		scanf("%lld", &tmp)+1;
		B.push_back(tmp);
	}
	for (int i = 0; i < Z; i++) {
		scanf("%lld", &tmp)+1;
		C.push_back(tmp);
	}

	vector<ll> AB;
	AB.reserve(X * Y);

	auto Aend = A.end();
	auto Bend = B.end();
	auto Bbeg = B.begin();
	for (auto Ait = A.begin(); Ait != Aend; Ait++) {
		for (auto Bit = Bbeg; Bit != Bend; Bit++) {
			AB.push_back(*Ait + *Bit);
		}
	}

	sort(AB.begin(), AB.end(), greater<ll>());
	if (X * Y > K) AB.resize(K);

	vector<ll> ABC;
	ABC.reserve(K);

	auto ABend = AB.end();
	auto Cend = C.end();
	auto Cbeg = C.begin();
	for (auto ABit = AB.begin(); ABit != ABend; ABit++) {
		for (auto Cit = Cbeg; Cit != Cend; Cit++) {
			ABC.push_back(*ABit + *Cit);
		}
	}

	sort(ABC.begin(), ABC.end(), greater<ll>());
	auto ABCit = ABC.begin();
	for (int i = 0; i < K; i++) {
		printf("%lld\n", *ABCit);
		ABCit++;
	}

	return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  vll a(n);
  ll sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  
  auto v=divisor(sum);
  
  ll ans=0;
  for(auto e: v){
    vll b(n);
    ll p=0;
    rep(i,n){
      b[i]=a[i]%e;
      p+=e-b[i];
    }
    vsort(b);
    ll m=0;
    rep(i,n){
      m+=b[i];
      p-=e-b[i];
      if(p==m && p<=k){
        chmax(ans,e);
        break;
      }
    }
  }
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
int main() {
	int N,  M;
	cin >> N >> M;
	vector<int> P(M);
	vector<string> S(M);
	vector<pair<int,string>> A(M);
	vector<int> rec1(N,0);
	vector<int> rec2(N, 0);
	int sum1 = 0;
	int sum2 = 0;
	for (int i = 0; i < M; i++) {
		cin >> P.at(i) >> S.at(i);
		A.at(i) = make_pair(P.at(i), S.at(i));
	}
	for (int i = 0; i < M; i++) {
		if (get<1>(A.at(i)) == "AC" && rec1.at(get<0>(A.at(i))-1) == 0) {
			rec1.at(get<0>(A.at(i))-1)++;
		}
		else if (get<1>(A.at(i)) == "AC" && rec1.at(get<0>(A.at(i))-1) != 0){
			continue;
		}
		else if (get<1>(A.at(i)) == "WA" && rec1.at(get<0>(A.at(i))-1) == 0){
			rec2.at(get<0>(A.at(i)) - 1)++;
		}
		else if (get<1>(A.at(i)) == "WA" && rec1.at(get<0>(A.at(i))-1) != 0) {
			continue;
		}
	}
	for (int i = 0; i < N; i++) {
		if (rec1.at(i) == 1) {
			sum1++;
			sum2=sum2+rec2.at(i);
		}
	}
	cout << sum1 << " " << sum2 << endl;
	return 0;
}

Measured memory_bytes: 8448
package main

import (
	"fmt"
)

func main() {
	var a, b int
	found := false
	fmt.Scan(&a, &b)
	for ans := 10; ans < 1010; ans++ {
		if ans*2/25 == a && ans/10 == b {
			fmt.Printf("%d\n", ans)
			found = true
			break
		}
	}
	if !found {
		fmt.Println("-1")
	}
}


Measured memory_bytes: 512
use proconio::input;

fn main() {
    input! {
        k: u128,
    }
    let div = if k % 7 == 0 {
        9 * k / 7
    } else {
        9 * k
    };

    if div % 2 == 0 || div % 5 == 0 {
        println!("{}", -1);
        return;
    }
    let mut count = 0;
    let mut remain = 10 % div;
    let ans = loop {
        count+=1;
        if remain == 1 {
            break count;
        }
        remain = remain * 10 % div;
    };
    println!("{}", ans);

}


Measured memory_bytes: 2124
//به نامش
//how we code is who we are :))
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
const ll MAXN = 2e6 + 10, inf = 1e18, mod = 1e9 + 7;

struct pair_hash {
	template <class T1, class T2>
		std::size_t operator () (const std::pair<T1,T2> &p) const {
			auto h1 = std::hash<T1>{}(p.first);
			auto h2 = std::hash<T2>{}(p.second);

			return h1 ^ h2;  
		}
};

ll pw(ll te, ll tee) {
	if (tee == 0)	return 1;
	ll res = pw(te, tee / 2);
	return (tee % 2 ? te * res * res : res * res);
}

ll a, b, t[MAXN], k;
vector<ll> v;

void Read_input() {
	cin >> a >> b >> k;
}

void Solve() {
	for (ll i = 1; i * i <= a; i++)
		if (a % i == 0) {
			t[i]++;
			if (i * i != a)	t[a / i]++;
		}
	for (ll i = 1; i * i <= b; i++)
		if (b % i == 0) {
			t[i]++;
			if (i * i != b) t[b / i]++;
		}
	for (ll i = 1; i < MAXN; i++)	if (t[i] > 1)	v.pb(i);
	sort(v.begin(), v.end(), [](ll i, ll j) {return i > j;});
	cout << v[k - 1];
}


int main() {

	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	//freopen("input.txt", "r", stdin),	freopen("output.txt", "w", stdout);

	Read_input(),	Solve();
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> prii;

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int dx8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}

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

    int N;
    cin >> N;
    set<int> s;
    rep(i, N) {
        int d;
        cin >> d;
        s.insert(d);
    }

    cout << s.size() << endl;

    return 0;
}


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

int main(){
    int a,b,c; cin >> a >> b;
    int ans = 1;
    c = a;
    if(b == 1){cout << 0 << endl; return 0;}
    while(1){
        if(c >= b){
            break;
        }
        c += a-1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>

using namespace std;

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

    int s[n];
    unsigned long long ans = 0;
    for(int i=0;i<n;i++){
        cin >> s[i];
        ans += s[i];
    }

    sort(s, s+n);
    if(ans%10!=0){
        cout << ans << endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if(s[i]%10!=0){
            ans -= s[i];
            break;
        }
        if(i==n-1)ans = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#define MAX 12
using namespace std;

int main()
{
    int N;
    while (cin >> N, N) {
        int n[MAX], t[MAX];
        for (int i = 0; i < N; i++) {cin >> n[i]; t[i] = n[i];}
        bool flag = true;
        int count = 0;
        while (flag) {
            map<int,int> m;
            for (int i = 0; i < N; i++) {
                m[n[i]]++;
            }
            for (int i = 0; i < N; i++)
                t[i] = m[n[i]];
            bool f = true;
            for (int i = 0; i < N; i++)
                if (t[i] != n[i]) f = false;
            if (f) flag = false;
            count++;
            for (int i = 0; i < N; i++) n[i] = t[i];
        }
        count--;
        cout << count << endl << t[0];
        for (int i = 1; i < N; i++) cout << " " << t[i];
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1196
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int q = Integer.parseInt(br.readLine());
      StringBuilder seqX = new StringBuilder();
      StringBuilder seqY = new StringBuilder();
      StringBuilder buf  = new StringBuilder();

      for(int i=0; i<q; i++) {
        seqX.append( br.readLine() );
        seqY.append( br.readLine() );

        buf.append( deriveLcs(seqX.toString(), seqY.toString()) )
           .append("\n");
        seqX.setLength(0);
        seqY.setLength(0);
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }

  private int deriveLcs(String seqX, String seqY) {
    int m = seqX.length();
    int n = seqY.length();
    int size = m > n ? m+1 : n+1;
    int[][] subSeq = new int[size][size];
    int maxSubSeq = 0;

    for(int i=1; i<=m; i++) subSeq[i][0] = 0;
    for(int j=1; j<=n; j++) subSeq[0][j] = 0;

    for(int i=1; i<=m; i++) {
      for(int j=1; j<=n; j++) {
        if(seqX.charAt(i-1) == seqY.charAt(j-1))
          subSeq[i][j] = subSeq[i-1][j-1] + 1;
        else
          subSeq[i][j] = Math.max(subSeq[i-1][j], subSeq[i][j-1]);

        maxSubSeq = Math.max(maxSubSeq, subSeq[i][j]);
      }
    }

    return maxSubSeq;
  }
}


Measured memory_bytes: 63836
#include <iostream>
#include <vector>
#include <map>

using namespace std;

#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int N, ans = 0;
vi A;
map<int, int> mp;

void solve(){
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if(itr->first <= itr->second )
            ans += itr->second - itr->first;
        else
            ans += itr->second;
    }
    cout << ans << endl;
}

int main(){
    cin >> N;
    A.resize(N);

    rep(i,N) {
        cin >> A[i];
        mp[A[i]]++;
    }

    solve();
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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

    double x = (L / 3.0);
    double ans = x * x * x;
    cout << fixed << setprecision(15) << ans << endl;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll lim = 1e6;
  ll N; cin >> N;
  vector<char> vec(lim + 1);
  for (ll i = 0; i < N; i++) {
    ll a; cin >> a;
    vec.at(a) += 1;
  }
  ll cnt = 0;
  for (ll i = 1; i <= lim; i++) {
    if (vec.at(i) == 0) continue;
    if (vec.at(i) == 1) cnt++;
    for (ll t = i * 2; t <= lim; t += i) vec.at(t) = 0;
  }
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 4228
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;


int main(int argc, const char * argv[]) {
  
  vector<bool> primes(60000, true);
  primes[0] = false;
  primes[1] = false;
  for(int i=0; i*i<60000; i++){
    if(not primes[i]) continue;
    for(int j=2*i; j<60000; j+=i)
      primes[j] = false;
  }
  
  vector<int> ans;
  for(int i=0; i<primes.size(); i++)
    if(primes[i] && (i%10 == 1)) ans.push_back(i);
  assert(ans.size()>=55);
  
  int N; cin >> N;
  for(int i=0; i<N; i++) cout << ans[i] << " ";
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int A,B;
    
    scanf("%d %d",&A,&B);
    
    if ((A-B*2) > 0) {
        printf("%d\n",A-B*2);
    } else {
        printf("0\n");
    }
    
    return 0;
}

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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  string S;

  cin >> N >> S;

  if (N == 1) {
    cout << 1 << endl;
    return 0;
  }

  int result = 1;
  char prev = '\0';

  REP(i, N) {
    if (prev == '\0') {
      prev = S[i];
    }

    if (S[i] != prev) {
      ++result;
      prev = S[i];
    }
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Threading.Tasks;

/*
・概要
LIS（Longest Increasing Subsequence：最長増加部分列）を求める。
任意のIComparebleタイプに対して使用可能。
LISはリストとして、その長さはintで返ってくる。

配列の各要素に対して二分探索をしているので、計算量は O(N * logN)の筈。
（Nは配列の要素数）

（e.g. LSIとは。
例えば、数列「1 3 5 2 4 6」だと、「1 2 4 6」の部分がLSIである。
この時の長さは4。
）

・ライブラリの使用法
1. LSIを求めたい配列を引数にして、class LSIのインスタンスを作成
（e.g. int配列の場合
	LSI<int> solve = new LSI<int>(originalArr);
）

2. LSI、若しくはLSIの長さを、メソッドを通じて取得する
（e.g. int配列の場合
	//LSIを取得
	List<int> lsi = solve.GetLSI();
	//LSIの長さを取得
	int len = solve.GetLength();
）

・アルゴリズムの詳細

・注意
	二分探索を自分で実装しているので、遅い and/or バグありかも？
*/


class Program
{
	//Main
	static void Main(string[] args)
	{
		//読み込む
		int N = int.Parse(Console.ReadLine());

		//対象となる配列を読み込む
		int[] originalArr = new int[N];
		for(int i=0; i<N; i++){
			//読み込む
			int c = int.Parse(Console.ReadLine());
			originalArr[i] = c;
		}

		//LSIオブジェクト
		LSI<int> solve = new LSI<int>(originalArr);

		//LSIを取得
		List<int> lsi = solve.GetLSI();
		//LSIの長さを取得
		int len = solve.GetLength();

		/*debug
		//LSIを表示
		foreach(int num in lsi){
			Console.Write("{0},", num);
		}
		Console.WriteLine("");
        */
		//LSIの長さを表示
		Console.WriteLine(len);
	}
}

class LSI<T>
	where T : IComparable
{
	//元の配列
	T[] originalArr;
	//LSI（DPによって作成）
	List<T> DP;

	public LSI(T[] array){
		//DP用のリスト（増加列の長さに対して、可能な最小値を代入する）を作成
		this.originalArr = array;
		this.DP = new List<T>();
	}

	//LSIの長さを返す
	public int GetLength(){
		this.SetLSI();
		return this.DP.Count();
	}

	//LSIを返す
	public List<T> GetLSI(){
		this.SetLSI();
		return this.DP;
	}

	//入力された配列に於けるLSIを確定させる
	void SetLSI(){
		//既にLSIが確定済みの場合、何もしない
		if(this.DP.Count() > 0){
			return;
		}
		else{
			T[] array = this.originalArr;

			//最初の要素を加えて初期化
			this.DP.Add(array[0]);

			//残りの要素について順次ループ処理
			int len = array.Length;
			for(int i=1; i<len; i++){
				//対象
				T target = array[i];
				//最終行よりも大きい場合、付け加える（DP[len-1] < target）
				if(this.DP[this.DP.Count()-1].CompareTo(target) < 0){
						this.DP.Add(target);
				}
				//その他の場合、二分探索を行い挿入位置を探す
				else{
						int idx = this.Bisect(target);
						this.DP[idx] = target;
				}
			}
		}
	}

	//二分探索
	int Bisect(T target){
		List<T> list = this.DP;

		//最小の場合（target <= list[0]）
		if(target.CompareTo(list[0]) <= 0){
			return 0;
		}
		else{
			//長さを取得
			int len = list.Count();

			//両端を初期化
			int max = len-1;
			int min = 0;
			int mid = (max+min)/2;

			//二分探索（条件を満たすまで探索）
			while(max-min > 1){
					//midより大きい場合（target > list[mid]）
					if(target.CompareTo(list[mid]) > 0){
							min = mid;
					}
					//小さい場合
					else{
							max = mid;
					}

					//中央を更新
					mid = (max+min)/2;
			}

			//置き換えるべきインデックスを出力
			return max;
		}
	}
}



Measured memory_bytes: 22348
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	rep(snip_i, n) cin >> a.at(snip_i);
	sort(a.begin(), a.end(), greater<int>());
	int x = -1, y = -1;
	rep(i, n-1){
		if(a.at(i) == a.at(i+1)){
			if(x == -1){
				x = a.at(i);
				i++;
			}else{
				y = a.at(i);
				break;
			}
		}
	}
	if(y == -1) cout << 0 << endl;
	else cout << (ll)x * (ll) y << endl;
	return 0;
}

Measured memory_bytes: 640
from collections import deque


def main():
    n, m = map(int, input().split())
    g = [[] for _ in range(n)]

    for _ in range(m):
        a, b = map(int, input().split())
        a, b = a - 1, b - 1
        g[a].append(b)
        g[b].append(a)

    q = deque([0])
    chk = [False] * n
    res = [0] * n

    while q:
        x = q.popleft()
        for y in g[x]:
            if chk[y]:
                continue
            chk[y] = True
            res[y] = x
            q.append(y)
    print("Yes")
    for i in res[1:]:
        print(i + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 95264
#include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define rep(i, n) for (lint i = 0; i < lint(n); ++i)
const lint mod = 1000000007LL;

lint modpow(lint x, lint n, lint m) {
	lint ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (m <= ans) ans %= m;
		}
		x *= x;
		if (m <= x) x %= m;
		n >>= 1;
	}
	return ans;
}

lint fact[1000000];
void f_init(lint n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (lint i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

lint comb(lint n, lint r) {
	if (n < r) return 0;
	if (n == r) return 1;
	lint ans = fact[n] * modpow(fact[n - r], mod - 2, mod) % mod * modpow(fact[r], mod - 2, mod) % mod;
	if (ans < 0) return ans + mod;
	return ans;
}

lint n, m, k, ans;
lint a[100010];
int main() {
	scanf("%lld %lld", &n, &k);
	f_init(n + 10);
	rep(i, n) {
		scanf("%lld", &a[i]);
	}
	sort(a, a + n);
	m = n - k + 1;
	rep(i, m) {
		ans += comb(n - m + i, k - 1) * (a[i + n - m] - a[m - 1 - i]);
		if (0 < ans) ans += mod;
		ans %= mod;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

char s[200];

int main(){
	cin >> s + 1;
	int len = strlen(s + 1);
	int ans = 0;
	for(int i = 2;i <= len - 1;i++) ans++;
	printf("%c%d%c",s[1],ans,s[len]);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int32_t main(){
	int r,c,k;
	cin>>r>>c>>k;
	for(int i=0;i<=r;i++){
		for(int j=0;j<=c;j++){
			//cout<<i<<" "<<j<<" "<<i*c+j*r-2*i*j<<"\n";
			if((i*c + j*r - 2*i*j)==k){
				cout<<"Yes\n";
				return 0;
			}
		}
	}
	cout<<"No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int n;
long long s;
int main () {
    cin >> n;
    for(long long int i = 1; i <= n; i++) {
        long long int q = n / i;
        s += i * q * (q + 1) / 2;
    }
    cout << s;
}


Measured memory_bytes: 3564
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <map>
typedef long long ll;
ll MOD = 998244353;

using namespace std;

ll kai[300001];
ll gyaku[300001];

//ユークリッド
ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	else
		return gcd(b,a%b);
}
//拡張ユークリッド
ll extgcd(ll a,ll b,ll &x,ll &y)
{
	ll d=a;
	if(b!=0)
	{
		d=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}else{
		x=1;
		y=0;
	}
	return d;
}

//逆元
ll inver(ll a)
{
	ll x,y;
	extgcd(a,MOD,x,y);
	return (MOD+x%MOD)%MOD;
}

//(nCp)*(nCq)を求める
ll combi(ll n,ll p,ll q)
{
	ll ret;
	ret=kai[n]*kai[n];
	ret%=MOD;
	ret*=inver(kai[p]);
	ret%=MOD;
	ret*=inver(kai[q]);
	ret%=MOD;
	ret*=inver(kai[n-p]);
	ret%=MOD;
	ret*=inver(kai[n-q]);
	ret%=MOD;
	while(ret<0)
		ret+=MOD;
	return ret;
}

int main()
{
	int n;
	ll a,b;
	ll k;
	ll g;//gcd
	ll l;//lcm
	ll xx,yy;
	ll ans=0;
	
	cin>>n>>a>>b>>k;
	g=gcd(a,b);
	l=a*b/gcd(a,b);
	if(k==0)
	{
		cout<<1<<endl;
		return 0;
	}
	if(k%g!=0)
	{
		cout<<0<<endl;
		return 0;
	}
	kai[0]=1;
	gyaku[0]=inver(0);
	for(int i=1;i<300001;i++)
	{
		gyaku[i]=inver(i);
		while(gyaku[i]<0)
			gyaku[i]+=MOD;
		kai[i]=kai[i-1]*i;
		kai[i]%=MOD;
		while(kai[i]<0)
			kai[i]+=MOD;
	}
	extgcd(a,b,xx,yy); //ax+by=gcd(a,b)を解く
	//cerr<<xx<<" "<<yy<<endl;
	xx*=(k/g);
	yy*=(k/g);
	ll d=xx/(l/a)+1LL;
	xx-=d*(l/a);
	yy+=d*(l/b);
	//順番に検証する
	while(yy>0)
	{
		if(xx>0)
		{
			//cerr<<xx<<" "<<yy<<endl;
			if(xx<=n && yy<=n)
			{
				ll temp=combi(n,xx,yy);
				ans+=temp;
				ans%=MOD;
				//cerr<<temp<<endl;
			}
		}
		xx+=(l/a);
		yy-=(l/b);
	}
	while(ans<0)
		ans+=MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
static const int MAX = 100000;
static const int NIL = -1;

int n;
vector<int> G[MAX];
int color[MAX];

void dfs(int r, int c){
	stack<int> S;
	S.push(r);
	color[r] = c;
	while (!S.empty()){
		int u = S.top(); S.pop();
		for(int i = 0; i < G[u].size(); i++){
			int v = G[u][i];
			if(color[v] == NIL){
				color[v] = c;
				S.push(v);
			}
		}
	}
}

void assignColor(){
	int id = 1;
	for(int i = 0; i<n; i++) color[i] = NIL;
	for(int u = 0; u<n; u++) {
		if(color[u] == NIL) dfs(u,id++);
	}
}

int main(){
	int s,t,m,q;
	
	cin >> n >> m;
	
	for(int i = 0; i < m; i++) {
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	
	assignColor();
	
	cin >> q;
	
	for(int i = 0; i < q; i++ ) {
		cin >> s >> t;
		if(color[s] == color[t]) {
			cout << "yes" << endl;
		}else{
			cout << "no" << endl;
		}
	}
	
	return 0;
}


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

using namespace std;


#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back

const int N = 1e6 + 1, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;


signed main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);
   int A, B, C, kol = 0;
   cin >> A >> B >> C;
   for (int i = 0; i < 1e6; i++) {
      if (A % 2 || B % 2 || C % 2) {
         cout << i;
         return 0;
      }
      int o = A / 2, o1 = B / 2, o2 = C / 2;
      A = o, B = o1, C = o2;
      A = o1 + o2, B = o + o2, C = o1 + o;
     //cout << A << ' ' << B << ' ' << C << endl;
   }
   cout << -1;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;
typedef pair<int, int> pii;

struct UnionFind{
    // 重みなしunionFind
    vector<int> par;
    vector<int> rank;
    UnionFind(int n){
        par = vector<int>(n, -1);
        rank = vector<int>(n, 0);
    }

    int root(int x){
        if(par[x] < 0){
            return x;
        }
        return par[x] = root(par[x]);
    }

    bool isSame(int x, int y){
        return root(x) == root(y);
    }

    bool merge(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y){
            return false;
        }
        if(rank[x] < rank[y]){
            swap(x, y);
        }
        if(rank[x] == rank[y]){
            rank[x] ++;
        }
        par[x] += par[y];
        // par[root]はroot以下のノード数 * -1
        par[y] = x;
        return true;
    }

};

struct edge{
    // edgeをsortして最小辺から処理するのでfromがないとだめ
    int from;
    int to;
    int cost;
    bool operator<(const edge& e) const{
        return cost < e.cost;
    }
};

struct Kruskal {
    int v;
    vector<edge> edges;
    Kruskal(int n, vector<edge> es){
        v = n;
        edges = es;
    }

    ll kruskal(){
        UnionFind uf(v);
        sort(edges.begin(), edges.end());

        ll min_cost = 0;

        for(edge e : edges){
            if(! uf.isSame(e.to, e.from)){
                min_cost += e.cost;
                uf.merge(e.to, e.from);
            }
        }
        return min_cost;
    }
};



int main(){
    int N;
    cin >> N;
    vector<pii>  xs;
    vector<pii>  ys;
    rep(i, N){
        int x, y;
        cin >> x >> y;
        pii px = {x, i};
        pii py = {y, i};
        xs.push_back(px);
        ys.push_back(py);
    }
    // dist(a,c) = dist(a,b) + dist(b,c)
    // なので隣接する場合だけ計算しておけば十分.
    sort(xs.begin(), xs.end());
    sort(ys.begin(), ys.end());

    vector<edge> edges;

    for(int i = 0;i < N - 1; i ++){
        int costx = abs(xs[i].first - xs[i + 1].first);
        edge ex = {xs[i].second, xs[i + 1].second, costx};
        int costy = abs(ys[i].first - ys[i + 1].first);
        edge ey = {ys[i].second, ys[i + 1].second, costy};
        edges.push_back(ex);
        edges.push_back(ey);
    }
    Kruskal k(N, edges);
    ll ans = k.kruskal();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10212
# coding: utf-8

n = int(input().rstrip())

numbers = list(map(int, input().rstrip().split(" ")))

start = 0
ans = 0
for i in range(1,n):
    if numbers[i] != numbers[i - 1]:
        tmp = i - start
        ans += int(tmp/2)
        start = i

ans += int((n-start)/2)

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
#define prtarr(n,len) {for(int i=0;i<len;i++) cout<<n[i]<<" ";}
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
using namespace std;
int n;
vll lists;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    cin>>n;
    vll dp(n,0);
    ll sum=0;
    for(int i=0;i<n;i++){
        ll sub;
        cin>>sub;
        sum+=sub;
        lists.pb(sub);
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        if(i==0) dp[i]=sum;
        else dp[i]=(dp[i-1]-lists[i-1]);
    }
    for(int i=0;i<n-1;i++){
        ans+=((dp[i+1]%MOD)*lists[i])%MOD;
    }
    cout<<ans%MOD;
    return 0;
}

Measured memory_bytes: 6856
%:pragma GCC optimize("Ofast", "inline", "-ffast-math")
#include <bits/stdc++.h>
#define rep(i, n) for (rint i = 1; i <= (n); i ++)
#define re0(i, n) for (rint i = 0; i < (int) n; i ++)
#define travel(i, u) for (rint i = head[u]; i; i = e[i].nxt)
#define rint register int
  using namespace std;

typedef long long lo;

template<typename tp> inline void read(tp &x) {
  x = 0; char c = getchar(); int f = 0;
  for (; c < '0' || c > '9'; f |= c == '-', c = getchar());
  for (; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if (f) x = -x;
}
namespace {
  const int mo = 1e9 + 7;
  inline int add(int x, int y) {
    if ((x += y) >= mo) x -= mo;
    return x;
  }
  inline int sub(int x, int y) {
    if ((x -= y) < 0) x += mo;
    return x;
  }
  inline int mul(int x, int y) {
    return 1LL * x * y % mo;
  }
  inline void U(int &x, int y) {
    x = add(x, y);
  }
  inline int power(int a, int k) {
    int ans = 1;
    for (; k; k >>= 1, a = mul(a, a))
      if (k & 1) ans = mul(ans, a);
    return ans;
  }
}
const int N = 333;
int n, rank_c, c[N][N], dp[N][N];
bool visit[N];
bitset <N> d[N], l[N];

int main(void) {
  read(n);
  rep (i, n) rep (j, n) read(c[i][j]);
  rep (j, n) rep (i, n) d[j][i] = c[i][j];
  rep (j, n) {
    for (int wei = n; wei >= 1; wei--)
      if (d[j][wei] == 1) {
	if (!visit[wei]) {
	  l[wei] = d[j];
	  visit[wei] = true;
	  ++rank_c;
	  break;
	}
	d[j] ^= l[wei];
      }
  }
  dp[0][0] = 1;
  re0 (i, n + 1) re0 (j, n + 1) {
    U(dp[i + 1][j], mul(power(2, j), dp[i][j]));
    U(dp[i + 1][j + 1], mul(sub(power(2, n), power(2, j)), dp[i][j]));      
  }
  int ans = 0;
  re0 (i, n + 1) if (i >= rank_c)
    U(ans, mul(dp[n][i], mul(power(2, n * (n - i)), dp[i][rank_c])));
  cout << mul(power(dp[n][rank_c], mo - 2), ans) << "\n";
}


Measured memory_bytes: 1152
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
public class Main {
	public static void main(String[] args) {
		Map<Integer,Integer> list = new TreeMap<>();
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for(int i = 1; i <= N; i++) {
			list.put(sc.nextInt(),i);
		}
		
		for(Integer str:list.keySet()){
		      System.out.print(list.get(str)+" ");
		    }
		
	}
}

Measured memory_bytes: 70460
#include <bits/stdc++.h>
//Solved by: Juan Sebastian Reina Zamora.
using namespace std;
//Recursive definition.
/*
int minimumCost(int* h, int N){
if( N == 0 || N == 1){
    return 0;
}else if (N == 2){
return abs(h[0] - h[1]);
}else if (N > 2){
 return min(minimumCost(h,N-1)+abs(h[N-2]-h[N-1]) ,minimumCost(h,N-2)+abs(h[N-3]-h[N-1]));
}
}*/

//Now using memoization =)
int minimumCost(int* h, int N, int* cost){
cost[0]=0;
cost[1]=0;
cost[2]=abs(h[0] - h[1]);
for(int i = 3;i<N;i++){
cost[i] = min(cost[i-1]+abs(h[i-2]-h[i-1]) ,cost[i-2]+abs(h[i-3]-h[i-1]));
}
return min(cost[N-1]+abs(h[N-2]-h[N-1]) ,cost[N-2]+abs(h[N-3]-h[N-1]));
}

int main(){
    int N;
    cin>>N;
    int* h = new int[N];
    for(int i = 0; i<N; i++){
      cin>>h[i];
    }
    int* cost = new int[N];
    cout<<minimumCost(h,N,cost)<<endl;
    delete[]h;
    return 0;
}

Measured memory_bytes: 1024
import numpy as np

def main_():
    N,W=map(int,input().strip().split())
    l=[]
    for n in range(N):
        l.append(list(map(int,input().strip().split())))
    
    dp=np.zeros(W+1,np.int64)

    for n in range(N):
        w=l[n][0]
        v=l[n][1]
        dp[w:]=np.maximum(dp[w:],dp[:-w]+v)
    return dp.max()

if __name__=="__main__":
    print(main_())

Measured memory_bytes: 29908
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if( (s[i]>='a'&&s[i]<='z') || (s[i]>='A'&&s[i]<='Z') )
			s[i]='x';
	}
	cout<<s<<endl;
	return 0;
}
	

Measured memory_bytes: 256
n = input()
_h = input()
_h = list(map(int, _h.split(' ')))

ans = 0

for i, h in enumerate(_h):
    if i == 0:
        max_h = h
        ans = ans + 1
        continue
    
    if h < max_h:
        continue
    else:
        max_h = h
    
    if h >= _h[i-1]:
        ans = ans + 1

print(ans)

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n, x; cin >> n >> x;
    ll a[n];
    ll sum = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    if(sum == x){
        cout << n << endl;
        return 0;
    }
    sum = 0;
    sort(a, a + n);
    int i;
    for(i=0;i<n;i++){
        if(sum + a[i] > x) break;
        sum += a[i];
    }
    if(i == n) cout << n - 1 << endl;
    else cout << i << endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
n = int(input())
a = input().split()
a = [int(m) for m in a]
t1 = []
t2 = []
mt3 = []
for i in range(3 * n):
    if i < (3 * n) // 3:
        t1.append(a[i])
    elif (3 * n) // 3 <= i < (3 * n) // 3 * 2:
        t2.append(a[i])
    else:
        mt3.append(-a[i])
t1.sort()
mt3.sort()
t1sumli = [sum(t1)]
t3sumli = [-sum(mt3)]
for i in range(n):
    pp = heappop(t1)
    heappush(t1, max(pp, t2[i]))
    t1sumli.append(t1sumli[-1] - pp + max(pp, t2[i]))

for i in range(n - 1, -1, -1):
    qq = -heappop(mt3)
    heappush(mt3, -min(qq, t2[i]))
    t3sumli.append(t3sumli[-1] - qq + min(qq, t2[i]))

sumli = []
for i in range(n + 1):
    sumli.append(t1sumli[i] - t3sumli[-i-1])
print(max(sumli))

Measured memory_bytes: 37212
#include<iostream>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if( a > b && a > c){
        cout << "A" << endl;
    }
    else if( b > a && b > c){
        cout << "B" << endl;
    }
    else if(c > a && c > b){
        cout << "C" << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <stdio.h>
#include <string>
#include<algorithm>
using namespace std;
 

int main(){
    int N;
    scanf("%d",&N);
    long long int a[N];
    int i=0;
    for(i=0;i<N;i++){
        scanf("%lld",&a[i]);
    }

    sort(a,a+N);
    bool m1=0;
    bool m2=0;
    long long int max1=a[N-1];
    for(i=N-2;i>-1;i--){
        if(a[i]==max1){
            m1=true;
            break;
        }else{
            max1=a[i];
        }
    }
    long long int max2=a[i-1];
    for(i=i-2;i>-1;i--){
        if(a[i]==max2){
            m2=true;
            break;
        }else{
            max2=a[i];
        }
    }
    if(m1 && m2){
        cout <<max1*max2<<endl;
        return 0;
    }else{
        cout << 0 << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

const int N = 300;
int n;
int a[N];
int ans = (int)1e9;

int sqr(int x)
{
	return x * x;
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int x = -N; x <= N; x++)
	{
		int y = 0;
		for (int i = 0; i < n; i++)
			y += sqr(x - a[i]);
		ans = min(ans, y);
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,m,l;
    cin >> n >> m >> l;
    long long int a[n][m],b[m][l],c[n][l] = {};
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < m;j++)
        {
            cin >> a[i][j];
        }
    }
    for(int i = 0;i < m;i++)
    {
        for(int j = 0;j < l;j++)
        {
            cin >> b[i][j];
        }
    }
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < l;j++)
        {
            for(int k = 0;k < m;k++)
            {
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < l;j++)
        {
            cout << c[i][j];
            if(j != l - 1)
            {
                cout << " ";
            }
        }
        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 3328
def main():
	n, k = map(int, input().split())
	ans = 0

	for i in range(1, n + 1):
		x = 0
		while i < k:
			i <<= 1
			x += 1
		ans += (1 / n) / (1 << x)

	print(ans)

	return 0

main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int MAX_N=5+2e5;
struct SEG{
	struct Node{
		int k[2]; bool tag;
	}t[MAX_N<<2];
	inline void put_tag(int x,bool tag){
		if(!tag) return;
		swap(t[x].k[0],t[x].k[1]);
		t[x].tag^=1;
	}
	inline void down(int x){
		put_tag(x+x,t[x].tag);
		put_tag(x+x+1,t[x].tag);
		t[x].tag=0;
	}
	inline void up(int x){
		t[x].k[0]=t[x+x].k[0]+t[x+x+1].k[0];
		t[x].k[1]=t[x+x].k[1]+t[x+x+1].k[1];
	}
	void init(string& s,int p,int l,int r){
		if(l==r){
			t[p].k[0]=t[p].k[1]=t[p].tag=0;
			if(s[l]=='1')
				t[p].k[~l&1]=1;
			return;
		}
		int m=l+r>>1;
		init(s,p+p,l,m);
		init(s,p+p+1,m+1,r);
		up(p);
	}
	void change(int p,int l,int r,int x,int y,bool tag){
		if(y<l||r<x) return;
		if(x<=l&&r<=y) return put_tag(p,tag);
		int m=l+r>>1; down(p);
		change(p+p,l,m,x,y,tag);
		change(p+p+1,m+1,r,x,y,tag);
		up(p);
	}
	int query(int p,int l,int r,int x,int y){
		if(y<l||r<x) return 0;
		if(x<=l&&r<=y) return t[p].k[1];
		int m=l+r>>1; down(p);
		return query(p+p,l,m,x,y)+query(p+p+1,m+1,r,x,y);
	}
}seg;
int tran(string& s,string& s1,char c='\n'){
	s1.clear();
	int ret=0;
	for(int i=0;i<s.length();++i){
		if(s[i]=='1'){
			int j=i;
			while(s[j]=='1'&&s[j+1]=='1')
				j+=2;
			ret+=j-i;
			if(s[j]=='0') i=j-1;
			else{
				s1.push_back(s[j]);
				i=j;
			}
		}else{
			s1.push_back(s[i]);
		}
	}
	return ret;
}
bool vis[MAX_N];
int main(){
	int c1=0;
	string s,s1; cin>>s;
	c1=tran(s,s1,'1');
	int tp=(int)s1.length();
	seg.init(s1,1,0,tp-1);
//	cout<<s1<<endl;
	long long ans=c1/2+seg.query(1,0,tp-1,0,tp-1);
//	printf("[%lld]",ans);
	for(int i=0;i<s1.length();++i){
		if(s1[i]=='1'){
			if(seg.query(1,0,tp-1,i,i)==0){
				assert(vis[i-1]==0);
				vis[i-1]=1;
				seg.change(1,0,tp-1,i,tp-1,true);
				ans+=c1/2+seg.query(1,0,tp-1,0,tp-1);
//				printf("[%lld]",ans);
			}
		}
	}
	for(int i=(int)s1.length()-1;i>=0;--i)
		if(s1[i]=='0'&&!vis[i]){
			vis[i]=1;
			seg.change(1,0,tp-1,i,tp-1,true);
			ans+=c1/2+seg.query(1,0,tp-1,0,tp-1);
		}
	int c2=c1;
	for(int i=0;i<s1.length();++i) 
		if(s1[i]=='1') ++c2;
	while(c2>0){
		c2--;
		ans+=(c2+1)/2;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10240
#include <iostream>

using namespace std;

#define ll long long
#define pb push_back
#define st first
#define N 200005
#define nd second
#define ii pair<int,int>
#define fr freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	//fr
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>21)cout<<"bust";
	else cout<<"win";
}


Measured memory_bytes: 256