akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll MOD2 = 998244353;
const ll LLINF = (ll)1e18;
const ll INTINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max<T>(a,b);}
template <class T> void chmin(T& a, const T b){a=min<T>(a,b);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N; cin >> N;
	V<double> x(N);
	V<string> u(N);
	REP(i,N) cin >> x[i] >> u[i];
	REP(i,N) if(u[i]=="BTC") x[i] *= 380000;
	double ans = accumulate(ALL(x),0.);
	printf("%.10f",ans);
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+50;
int t,n,m;
int arr[maxn];
ll dp[maxn];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
	}
/*  	if(n%2==0)
	{
		ll fin0=0;
		ll fin1=0;
		for(int i=1;i<=n;i++)
		{
			if(i&1) fin1+=arr[i];
			else fin0+=arr[i];
		}
		cout<<max(fin0,fin1)<<endl;
		return 0; 
	}*/
	ll sum[maxn];
	sum[1]=arr[1];
	for(int i=3;i<=n;i+=2)
	{
		sum[i]=sum[i-2]+arr[i];
	}
	for(int i=2;i<=n;i++)
	{
		if(i%2==1)
		{
			dp[i]=max(dp[i-1],dp[i-2]+arr[i]);
		}
		else
		{
			dp[i]=max(sum[i-1],dp[i-2]+arr[i]);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

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

typedef long long ll;
using namespace std;
int main() {
  ll N, M;
  cin >> N >> M;

  vector<vector<ll>> switches(M);
  vector<ll> p(M);

  for (ll i = 0; i < M; i++) {
    ll k;
    cin >> k;
    for (ll j = 0; j < k; j++) {
      ll s;
      cin >> s;
      switches[i].push_back(s - 1);
    }
  }

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

  ll ans = 0;
  // スイッチの点灯状態を全探索
  // 0ビット目が1 -> 1個目のスイッチがON
  for (ll bit = 0; bit < (1<<N); bit++) {
    bool ok = true;
    // 全ての電球に対して、点灯するどうかチェックする
    for (ll i = 0; i < M; i++) {
      // onになっているスイッチの数
      ll ons = 0;
      for (auto s : switches[i]) {
        if (bit & (1 << s)) {
          ons++;
        }
      }
      // onになっているスイッチの数の余りを計算
      if (ons % 2 != p[i]) {
        ok = false;
        break;
      }
    }

    if (ok) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()



void solve(){
  ll n,m;
  cin >> n >> m;

  vll a(m);
  ll sum=0;
  rep(i,0,m) {
    cin >> a[i];
    sum+=a[i];
  }
  
  if(n>=sum) cout << n-sum << endl;
  else cout << -1 << endl;
  
}

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

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
//FAZAL_AHMAD
#define rep(i,a,b) for(long long i = (a); i < (b); i++)
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define pb push_back
using ll = long long;

ll lcm(ll a,ll b){

	return (a*b)/(__gcd(a,b));
}
void solve()
{
ll n;
cin>>n;
vector<ll> x,y;
for(ll i=0;i<n;i++){
	ll a,b;
	cin>>a>>b;
	x.pb(a-b);
	y.pb(a+b);
}

sort(all(x));
sort(all(y));
cout<<max(x[n-1]-x[0],y[n-1]-y[0]);

}



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

		solve();
	cout<<endl;


}






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

int main(void){
    int N, Q, M, d;
    map<int, int> date;
    while(cin >> N >> Q && N) {
        date.clear();
        rep(i, N) {
            cin >> M;
            rep(j, M) {
                cin >> d;
                date[d]++;
            }
        }
        map<int, int>::iterator it = date.begin();
        int size = 0, ans=numeric_limits<int>::max();
        while(it != date.end()) {
            if(size < (*it).second 
                    || (size == (*it).second && ans > (*it).first)) {
                size = (*it).second;
                ans = (*it).first;
            }
            it++;
        }
        if(size >= Q) cout << ans << endl;
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 1200
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int n,m,d;
	cin>>n>>m>>d;
	double x;
	if(d==0) x=1.0/n;else x=2.0*(n-d)/n/n;
	printf("%.12f\n",x*(m-1));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int check(int n){
    for(int i = 2; i < n / 2; i++){
        if(n % i == 0){
            return 0;
        }
    }
    cout << n << endl;
    return 1;
}
int main(){
    int x, i=0;
    cin >> x;
    while(1){
        if(check(x+i) == 1){
            return 0;
        }
        i++;
    }
}

Measured memory_bytes: 256
S = input()
let = ['KIH','B','R','']
ans = 'NO'
for i in range(2**4):
    cand = ''
    for j in range(4):
        if (i >> j) & 1 == 1:
            cand += 'A'
        cand += let[j]
    if cand == S:
        ans = 'YES'
        break
print(ans)

Measured memory_bytes: 3060
package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	n := 0
	fmt.Scan(&n)

	a := 0
	b := 0
	ba := 0
	ans := 0
	var s string
	for i := 0; i < n; i++ {
		fmt.Scan(&s)
		for j := 0; j < len(s)-1; j++ {
			if s[j] == 'A' && s[j+1] == 'B' {
				ans++
			}
		}

		first := s[0]
		last := s[len(s)-1]
		if first == 'B' && last == 'A' {
			ba++
		}
		if first == 'B' && last != 'A' {
			b++
		}
		if first != 'B' && last == 'A' {
			a++
		}
	}
	if ba == 0 {
		ans += min(a, b)
	} else {
		if a+b == 0 {
			ans += ba - 1
		} else {
			ans += min(a, b) + ba
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1024
/* be name khoda */

// #define stream_enable
#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl;
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl;
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl;
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl;
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl;
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = (a + (b)) % MOD
#define Mul(a, b) a = (a * (b)) % MOD

stringstream sss;

// -----------------------------------------------------------------------

const ll maxn = 1010;
const ll maxh = 10010;

ll h, n;
pii sp[maxn];
ll dp[maxh];

void MAIN() {

    cin >> h >> n;
    fori (i, n) {
        cin >> sp[i].F >> sp[i].S;
    }
    forifrom (i, 1, h + 1) {
        dp[i] = BIG;
        fori (j, n) {
            smin(dp[i], dp[max(0LL, i - sp[j].F)] + sp[j].S);
        }
    }
    cout << dp[h] << '\n';

}

// -----------------------------------------------------------------------

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(

    )";
    MAIN();
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int MX = 1'000'000 + 1;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> p(MX);
  for (int &i : a) {
    cin >> i;
    p[i]++;
  }
  int pw = 1;
  for (int i = 2; i < MX; i++) {
    int cnt = 0;
    for (int j = i; j < MX; j += i) cnt += p[j];
    if (cnt > 1) pw = 0;
  }
  if (pw) {
    cout << "pairwise coprime" << endl;
    return 0;
  }
  int g = 0;
  for (int i = 0; i < n; i++) g = gcd(g, a[i]);
  if (g == 1) {
    cout << "setwise coprime" << endl;
    return 0;
  }
  cout << "not coprime" << endl;
  return 0;
}

Measured memory_bytes: 11164
#include <iostream>
#include <string>
#include <stack>
#include <cstdlib>
#include <cstdio>
using namespace std;

stack<int> st;

int solve(string);

int main() {
    string str;
    while (cin >> str) {
        if (str == "+" || str == "-" || str == "*")
            st.push(solve(str));
        else st.push(atoi(str.c_str()));
        if (getchar()=='\n') {
            cout << st.top() << endl;
            return 0;
        }
    }
}

int solve(string str) {
    int b = st.top();
    st.pop();
    int a = st.top();
    st.pop();
    if (str == "+") return a + b;
    else if (str == "-") return a - b;
    else if (str == "*") return a * b;
}




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


  
int main(){
  

  int a,b;
  cin >> a>> b  ;
  if (a>b){
    cout << a-b << "\n";
  }else  if (b>a){
  cout <<b-a <<"\n"; }
  else {
    cout << "0\n";
  }
  
 return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,A,B,C,x,ans=0;
	cin>>A>>B>>C>>x;
	for(a=0;a<=A;a++){
		for(b=0;b<=B;b++){
			for(c=0;c<=C;c++){
				if(a*500+b*100+c*50==x) ans++;
			}
		}
	}
	cout<<ans;
}

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

bool is_ATGC(char s)
{
  return s=='A' || s=='T' || s=='G' || s=='C';
}

int main()
{
  string S;
  cin >> S;
  string::iterator itr;
  int tmp=0, tmpmax=0;
  for(itr=S.begin(); itr!=S.end(); itr++)
  {
    if(is_ATGC(*itr)){
      tmp++;
    } else {
      tmpmax = max(tmpmax,tmp);
      tmp = 0;
    }
  }
  tmpmax = max(tmpmax,tmp);
  cout << tmpmax << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

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


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
char s[200100];
int main()
{
    scanf("%s",s+1);
    int n=strlen(s+1);
    int cnt=0;
    long long ans=0;
    for(int i=1;i<=n;++i)
        if(s[i]=='W')
            ans+=cnt;
        else
            ++cnt;
    printf("%lld\n",ans);
    return 0;
}


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

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

    if(abs(a-c)<=d){
        cout << "Yes" << endl;
    }
    else if(abs(a-b)<=d && abs(b-c)<=d){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#define pii pair<int, int>
#define piii pair<int, pii>
#define pll pair<long long, long long>
#define plll pair<long long, pll>
#define ff first
#define ss second
#define ee ss.ff
#define rr ss.ss

using namespace std;

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

    int n; cin >> n;
    int x[n], d[n];
    for(int i = 0; i < n; ++i) cin >> x[i] >> d[i];

    pii arr[n];
    for(int i = 0; i < n; ++i) arr[i] = {x[i] - d[i], x[i] + d[i]};
    sort(arr, arr + n, [](pii x, pii y){return x.ss < y.ss;});

    int mx = -2e9;
    int ans = 0;
    for(auto i : arr)
    {
        if(i.ff < mx) continue;
        ++ans;
        mx = i.ss;
    }

    cout << ans;
    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int n;
  scanf("%d", &n);
  char buf[32] = { '\0' };
  vector<ll> freqs(128, 0LL);
  for (int i = 0; i < n; ++i) {
    scanf("%s", buf);
    int ch = buf[0];
    ++freqs[ch];
  }
  ll ans = 0;
  vector<int> initials = { 'M', 'A', 'R', 'C', 'H' };
  for (int i = 0; i < 5; ++i) {
    for (int j = i + 1; j < 5; ++j) {
      for (int k = j + 1; k < 5; ++k) {
        ll a = freqs[initials[i]], b = freqs[initials[j]], c = freqs[initials[k]];
        ans += a * b * c;
      }
    }
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
N, M = inpl()
INF = float("inf")

G = [[INF]*(N) for _ in range(N)]
E = []
for _ in range(M):
    a, b, c = inpl()
    G[a-1][b-1] = c
    G[b-1][a-1] = c
    E.append([a-1, b-1, c])

for k in range(N):
    for i in range(N):
        for j in range(N):
            G[i][j] = min(G[i][j], G[i][k] + G[k][j])

print(sum([G[a][b] < c for a, b, c in E]))

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll A, B;
    cin >> A >> B;
    if((A+B) % 2 == 0){
        cout << (A+B)/2 << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}



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


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


def solve():
    H, W = read_ints()
    for _ in range(H):
        C = input().strip()
        print(C)
        print(C)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 62560
const main = async () => {
  const input = require('fs').readFileSync('/dev/stdin', 'UTF-8').trim()

const num = parseInt(input).toLocaleString().split(',')
const answer = 1000 - parseInt(num[num.length - 1])

if (answer === 1000) {
  console.log('0');

} else {
  console.log(answer);

}
}

main()

Measured memory_bytes: 30856
#include<stdio.h>
#include<map>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<utility>
#include<string.h>
#include<string>
#define n 200000
#define loop(a, b) for(int i=a; i<=b; i++)
using namespace std;
typedef pair<int, int> P;
typedef long long lli;
typedef double llf;
bool visit[n + 50];
int arr[n + 50], a, b, c, d, e;
string str1, str2;
struct edge{
	int from, to, weight;
	bool operator < (const edge& thing) const
	{
		return thing.weight < weight;
	}
};
vector<edge> V[n + 50];
void addedge(int a, int b, int c)
{
	edge temp;
	temp.from = a;
	temp.to = b;
	temp.weight = c;
}

////////////////////////////////////////

void solve()
{
	cin >> a;
	loop(0, a - 1) cin >> arr[i];
	int counting = 0, ans = 0;
	loop(1, a - 1)
	{
		if(arr[i] <= arr[i - 1])
		{
			counting ++;
			ans = max(counting, ans);
		}
		else
		{
			counting = 0;
		}
	}
	cout << ans << '\n';
}
int main()
{
	int times = 1;
//	cin >> times;
	loop(0, times - 1)
	{
		solve();
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 5376
#include <stdio.h>
  
int Partition(int* A,int p,int r);
  
main(){
  int n,i,p,A[100000];
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  p = Partition(A,0,n-1);
  
  for(i=0;i<n;i++){
    if(p==i)printf("[%d]",A[i]);
    else printf("%d",A[i]);
if(i!=n-1) printf(" ");
  }
  printf("\n");
  
  return 0;
}
  
int Partition(int* A,int p, int r){
  
  int x, i,j, tmp;
  
  x = A[r];
  i = p-1;
  for(j=p; j<=r-1; j++){
  
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  
  }
      tmp = A[i+1];
      A[i+1] = A[r];
      A[r] = tmp;
  
  return i+1;
  
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int n;
  string s;
  cin>>n>>s;
  s.erase(unique(s.begin(),s.end()),s.end());
  cout<<(int)s.size()<<endl;
  return(0);
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	long long N;
	cin >> N;

	string s;
	//cin >> s;

	//int A[5]
	//sort(A, A + 5);

	if (N >= 30)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

}

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

using namespace std;


double dp[305][305][305];


// dp[one][two][three]
// 

int N=302;

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

    int n;
    cin>>n;
    vector<int> cnt(3+1);
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        cnt[x]++;
    }

    // dp[0][0][0]=1;
    for(int three=0;three<N;three++){
        for(int two=0;two<N;two++){
            for(int one=0;one<N;one++){
    // for(int three=0;three<=cnt[3];three++){
    //     for(int two=0;two<=cnt[2];two++){
    //         for(int one=0;one<=cnt[1];one++){
                if(one+two+three == 0){
                    continue;
                }
                if(one+two+three>n){
                    continue;
                }
                dp[one][two][three]=1;
                if(one!=0){
                    dp[one][two][three]+=(dp[one-1][two][three])*((double)one/n);
                }
                if(two!=0){
                    dp[one][two][three]+=(dp[one+1][two-1][three]*((double)two/n));
                }
                if(three!=0){
                    dp[one][two][three]+=(dp[one][two+1][three-1]*((double)three/n));
                }

                int zeroes=(n-one-two-three);
                dp[one][two][three]/=(1.0 - 1.0*zeroes/(double)(n));
            }
        }
    }
    cout<<setprecision(9)<<fixed;
    cout<<dp[cnt[1]][cnt[2]][cnt[3]]<<endl;
}

Measured memory_bytes: 112564
#include <iostream>
#include <string>
//typedef long long LL;
using namespace std;

int main(){
    string s;
    bool good = true;

    cin >> s;
    for(int i=0; i<3; i++){
        if(s[i]==s[i+1]){
            good = false;
        }
    }
    if(good){
        cout << "Good";

    }else{
        cout << "Bad";
    }
    cout << endl;
}

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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

template <unsigned m> struct Mint {
    Mint():val(0){}
    Mint(int raw):val((raw%m+m)%m){}
    Mint(long long raw):val((raw%m+m)%m){}
    Mint(unsigned raw):val(raw%m){}
    Mint(unsigned long long raw):val(raw%m){}
    friend Mint operator+(Mint a, Mint b) { return a.val + b.val; }
    friend Mint operator-(Mint a, Mint b) { return m + a.val - b.val; }
    friend Mint operator*(Mint a, Mint b) { return 1ll * a.val * b.val; }
    friend Mint operator/(Mint a, Mint b) { return a * qpow(b, m-2); }
    friend Mint& operator+=(Mint& a, Mint b) { return a = a + b; }
    friend Mint& operator-=(Mint& a, Mint b) { return a = a - b; }
    friend Mint& operator*=(Mint& a, Mint b) { return a = a * b; }
    friend Mint& operator/=(Mint& a, Mint b) { return a = a / b; }
    friend bool operator==(Mint a, Mint b) { return a.val == b.val; }
    friend bool operator!=(Mint a, Mint b) { return a.val != b.val; }
    friend ostream& operator<<(ostream& out, Mint x) { return out << x.val; }
    unsigned val;
};

using M = Mint<1'000'000'007>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto n = load<int>();
    auto compat = vector<vector<bool>>(n, vector<bool>(n));
    for (auto y=0; y<n; ++y)
        for (auto x=0; x<n; ++x)
            compat[x][y] = load<bool>();
    auto dyn = vector<vector<M>>(n+1, vector<M>(1 << n, 0)); // [x][ymask]
    dyn[0][0] = 1;

    auto lenmasks = vector<vector<int>>(n+1);
    for (auto mask=0; mask<1<<n; ++mask)
        lenmasks[__builtin_popcount(mask)].push_back(mask);
    

    for (auto x=0; x<n; ++x)
        for (auto ymask : lenmasks[x])
            for (auto y=0; y<n; ++y)
                if (compat[x][y] and (ymask & (1 << y)) == 0)
                    dyn[x+1][ymask | (1 << y)] += dyn[x][ymask];
    cout << dyn[n][(1<<n)-1] << '\n';
}


Measured memory_bytes: 195324
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main() {
	int n,a,b;
	cin>>n>>a>>b;
	if(a*n>b)cout<<b<<endl;
	if(a*n<=b)cout<<n*a<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;

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


const int MAX = 510000;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


//素因数分解
vector<pair<long long, int>> factorize(long long n) {
    vector<pair<long long, int>> res;
    for (long long i = 2; i * i <= n; ++i) {
        if (n % i != 0) continue;
        res.emplace_back(i, 0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}
vector<int> c;
void f(const vector<pair<ll, int>>& v,int ind, int x) {
    if (ind == v.size()) {
        c[x]++;
        return;
    }
    int b = 1;
    rep(i, v[ind].second + 1) {
        f(v, ind + 1, x * b);
        b *= v[ind].first;
    }
}

//正剰余
long long mod(long long a, long long b)
{
    return a - (long long)std::floor((double)a / (double)b) * b;
}
int main() {
    COMinit();
    int N, K;
    cin >> N >> K;
    c.resize(K+1);
    rep(i, K + 1)c[i] = 0;
    repi(i, 1, K + 1) {
        f(factorize(i), 0, 1);
    }
    vector<ll> sum(K+1);
    rep(i, K + 1)sum[i] = 0;
    for (int i = K; i >= 1; --i) {
        sum[i] = 1;
        ll b = c[i];
        for (int j = 0; (N >> j) > 0; j++) {
            if (((N >> j) & 1) == 1) sum[i] = (sum[i] * b) % MOD;
            b = (b * b) % MOD;
        }
        for (int j = 2; i * j <= K; ++j) sum[i] = mod(sum[i] - sum[i * j], MOD);
    }
    ll res = 0;
    rep(i, K + 1) {
        res += sum[i] * i;
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}



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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int N;

int dp[11][11][11];
int calc(int i, int h, int t)
{
  if(dp[i][h][t] != -1) return dp[i][h][t];
  if(i == 1) {
    if(h != t) return 0;
    if(h <= N) return 1;
    else return 0;
  }

  int ret = 0;
  int p = pow(10, i-1);
  int tmp = h*p + t;
  
  while(true) {
    if(tmp > N || tmp/p != h) break;
    ret++;
    tmp += 10;
  }

  return dp[i][h][t] = ret;
}

signed main()
{
  cin >> N;
  memset(dp, -1, sizeof(dp));

  int ans = 0;
  FOR(i,1,7) {
    FOR(j,1,7) {
      FOR(k,1,10) {
        FOR(l,1,10) {
          ans += calc(i, k, l) * calc(j, l, k);
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int isprime(int);

int main(){
  int n,a[10000],i,count=0;
  
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",&a[i]);
    if(isprime(a[i]) == 1)count++;
  }
  printf("%d\n",count);
  return 0;
}
int isprime(int a){
  int i;
  
  if(a <= 1)return 0;
  else if(a == 2)return 1;
  else if((a % 2) == 0)return 0;
  for(i = 3 ; i*i <= a; i+=2){
    if((a % i) == 0) return 0;
  }
  return 1;
}



Measured memory_bytes: 1956
#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9 + 10;
const int N = 1e6 + 10;
int n,l;
int v;
int a[N];
struct MinStack {
	stack< pair<int, int> > s;
	MinStack() {};
	bool empty() {
		return s.empty();
	}
	void push(int x) {
		int new_min = s.empty() ? x : min(x, s.top().second);
		s.emplace(make_pair(x, new_min));
	}
	int top() {
		return s.empty() ? INF : s.top().first;
	}
	int getMin() {
		return s.empty() ? INF : s.top().second;
	}
	void pop() {
		if(!s.empty()) s.pop();
	}
};
struct MinQueue {
	MinStack entrada, salida;
	MinQueue() {};
	void push(int x) {
		entrada.push(x);
	}
	void pop() {
		if(salida.empty()) {
			while(!entrada.empty()) {
				salida.push(entrada.top());
				entrada.pop();
			}
		}
		if(!salida.empty()) {
			salida.pop();
		}
	}
	int front() {
		if(salida.empty()) {
			while(!entrada.empty()) {
				salida.push(entrada.top());
				entrada.pop();
			}
		}
		return salida.top();
	}
	int getMin() {
		return min(entrada.getMin(), salida.getMin());
	}
} q;
int main() {
	scanf("%d %d", &n, &l);
	vector<int> ans;
	for(int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		q.push(a[i]);
		if(i >= l) {
			ans.emplace_back(q.getMin());
			q.pop();
		}
	}
	for(int i = 0; i < (int) ans.size(); ++i) {
		printf("%d%c", ans[i], i == (int) ans.size() - 1 ? '\n' : ' ');
	}
	return 0;
}


Measured memory_bytes: 11404
s = input()

if   s == 'SUN': print('7')
elif s == 'MON': print('6')
elif s == 'TUE': print('5')
elif s == 'WED': print('4')
elif s == 'THU': print('3')
elif s == 'FRI': print('2')
else: print('1')       

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
const ll N = 1e6 + 5;
const ll base = 313;
const ll base1 = 113;
const ll mod = 1e9 + 7;
ll n, t, pr[N], nx[N], T, k, b[N], c[N], sum= 0, m, tong, ans, pw1[N], pw[N];
struct dang
{
    ll l, r, pos;
};
ll a[N];
string s;
vector<ll> kq;
void sol()
{
    cin >> n >> k >> m;
    //ans = min(abs(n - k * m), abs(n + k * m));
    t = n % m;
    //cout << t <<" ";
    if(k >= abs((n - t) / m))
    {
        if((k - (n - t) / m  ) % 2  == 0)ans = abs(t);
        else ans = (m - abs(t));
    }
    else
    {
        if(n < 0)ans = abs(n + m * k);
        else ans = abs(n - m * k);
    }


    cout << ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    sol();
}


Measured memory_bytes: 3624
def SW_next(i, s, t):
    if t[i - 1] == 'S':
        if s[i - 1] == 'o':
            if t[i - 2] == 'S':
                return('S')
            else:
                return('W')
        else:
            if t[i - 2] == 'S':
                return('W')
            else:
                return('S')
    else:
        if s[i - 1] == 'o':
            if t[i - 2] == 'S':
                return('W')
            else:
                return('S')
        else:
            if t[i - 2] == 'S':
                return('S')
            else:
                return('W')

def SW_check(n, s, t):
    i = 2
    while i < n:
        t = t + SW_next(i, s, t)
        i += 1
    if t[0] == SW_next(n, s, t):
        tmp_s = [s[n - 1]]
        tmp_s.append(s[0])
        tmp_t = [t[n - 1]]
        tmp_t.append(t[0])
        if t[1] == SW_next(2, tmp_s, tmp_t):
            print(t)
            return(True)
    return(False)

n = int(input())
s = input()

if not SW_check(n, s, 'SS'):
    if not SW_check(n, s, 'SW'):
        if not SW_check(n, s, 'WS'):
            if not SW_check(n, s, 'WW'):
                print(-1)


Measured memory_bytes: 3444
# 初期入力
#import numpy as np
import sys
input = sys.stdin.readline
N,M = (int(i) for i in input().split())
A = list(map(int, input().split()))
take =[[-1] for i in range(M)]
for x in range(M):
    B,C = (int(i) for i in input().split())
    take[x] =B,C

#
A.sort()
take.sort(key=lambda x: x[1], reverse=True)
take =[(0,0)] +take
ind =[0]*(M+1)
for i in range(1,M+1): #初項に「０」足したから「M]まで
    ind[i] =ind[i-1] +take[i][0]
    if ind[i-1] >=N:
        break
    elif A[ind[i-1]] >=take[i][1]:
        break
    elif ind[i] <N and A[ind[i]] <take[i][1]: #全て一括で置き換える
        A[ind[i-1] :ind[i]] =[take[i][1] ] *(take[i][0]) 
    else:
        for j in range(ind[i-1],ind[i]): #最後は1つずつ確認しながら置き換える
            if N <= j:
                break
            if A[j] <take[i][1]:
                A[j] =take[i][1]
            else:
                break
print(sum(A))

Measured memory_bytes: 28336
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int n, a[3]; cin >> n >> a[0] >> a[1] >> a[2];
    string s[n]; for (int i = 0; i < n; i++) cin >> s[i];
    vector<char> ans;
    for (int i = 0; i < n; i++) {
        int p = s[i][0]-'A', q = s[i][1]-'A';
        if (a[p] == 0 && a[q] == 0) {
            cout << "No\n";
            return 0;
        } else if (a[p] == 0) {
            ans.push_back(s[i][0]);
            a[p]++;
            a[q]--;
        } else if (a[q] == 0) {
            ans.push_back(s[i][1]);
            a[p]--;
            a[q]++;
        } else {
            if (i == n-1) ans.push_back(s[i][1]);
            else {
                int p1 = s[i+1][0] - 'A', q1 = s[i+1][1] - 'A';
                for (int j = 0; j < 3; j++)
                    if ((p == j || q == j) && (p1 == j || q1 == j)) {
                        ans.push_back('A' + j);
                        a[j]++;
                        a[p+q-j]--;
                        break;
                    }
            }
        }
    }
    cout << "Yes\n";
    for (char c : ans) cout << c << endl;
}


Measured memory_bytes: 6856
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

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

const int inf = 1e9 + 7;
#define EPS 1e-9

int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> p(n);
	rep(i, n) cin >> p[i].second >> p[i].first;
	sort(p.begin(), p.end());
	int sum = 0;
	rep(i, n) {
		sum += p[i].second;
		if (sum > p[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> bool chmax(T &a, U b) { if (a < b) a = b; return true; }
template<class T, class U> bool chmin(T &a, U b) { if (a > b) a = b; return true; }

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007, MAX = 1000005;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);

  int n; cin >> n;
  vi a(n), cnt(MAX);
  
  rep(i, n) {
    cin >> a[i];
    ++cnt[a[i]];
  }

  int ans = 0;
  rep(i, n) {
    int add = 1;
    --cnt[a[i]];

    for (int j = 1; j * j <= a[i]; ++j) {
      if (a[i] % j) continue;
      if (cnt[j]) {
        add = 0;
        break;
      }
      if (cnt[a[i] / j]) {
        add = 0;
        break;
      }
    }

    ++cnt[a[i]];
    ans += add;
  }

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 7904
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}



void oneCase () {
    int a, b;
    cin >> a >> b;
    cout << (a + b - 1) / b << "\n";

}




int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    long long ans = 1;
    for (int i = 0; i < n; i++) {
        long long a;
        cin >> a;
        if (a == 0) {
            ans = 0;
            cout << ans << endl;
            return 0;
        }
        else if (a <= 1000000000000000000 / ans) {
            ans = ans * a;
        }
        else {
            ans = -1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
const int N=12,M=1e3+20,MAX=1e8;
int n,m,dp[1<<N],cost,b,x;
int main()
{
	scanf("%d%d",&n,&m);

	for(int mask=0;mask<(1<<n);mask++) dp[mask]=MAX;
	dp[0]=0;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d",&cost,&b);

		int mask=0;
		vector <int> v;
		while(b--) cin>>x,mask^=(1<<(x-1));
		for(int i=0;i<(1<<n);i++)
		{
			int new_mask=0;
			for(int j=0;j<n;j++)
				if((mask&(1<<j)) or (i&(1<<j)))
					new_mask^=(1<<j);
			dp[new_mask]=min(dp[new_mask],dp[i]+cost);
		}
	}

	if(dp[(1<<n)-1]==MAX) dp[(1<<n)-1]=-1;
	printf("%d",dp[(1<<n)-1]);
}

Measured memory_bytes: 384
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }

    Scanner cin;
    
    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int a = 0;
        int b = 0;
        string S = cin.next();
        foreach (var c in S)
        {
            if(c == '(')
            {
                b++;
            }
            else
            {
                b--;
                if(b < 0)
                {
                    b++;
                    a++;
                }
            }
        }
        Console.WriteLine(new string('(', a) + S + new string(')', b));
    }


        
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}
 

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

int main(){
  int n;
  ll k;
  cin>>n>>k;
  ll a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n);
  
  ll fu,zero,sei;
  fu=lower_bound(a,a+n,0)-a;
  zero=upper_bound(a,a+n,0)-lower_bound(a,a+n,0);
  sei=n-fu-zero;
  
  ll f,z,s;
  f=fu*sei;
  z=(fu+sei)*zero+zero*(zero-1)/2;
  s=sei*(sei-1)/2+fu*(fu-1)/2;
  
  if(k<=f){
    ll l=1;
    ll r=1e18;
    while(l<r){
      ll x=(l+r)/2;
      ll p=0;
      int q=0;
      rep(i,0,(int)fu){
        while(q<sei && (-a[i])*a[fu+zero+q]<=x) q++;
        p+=q;
      }
      if(p<f-k+1) l=x+1;
      else r=x;
    }
    cout<<-r<<endl;
  }
  
  else if(k<=f+z){
    cout<<0<<endl;
  }
  
  else{
    ll l=1;
    ll r=1e18;
    while(l<r){
      ll x=(l+r)/2;
      ll p=0;
      int q=0;
      rep(i,0,(int)sei){
        while(q<sei-1-i && a[n-1-i]*a[fu+zero+q]<=x) q++;
        p+=min(q,(int)sei-1-i);
      }
      q=0;
      rep(i,0,(int)fu){
        while(q<fu-1-i && a[i]*a[fu-1-q]<=x) q++;
        p+=min(q,(int)fu-1-i);
      }
      if(p<k-f-z) l=x+1;
      else r=x;
    }
    cout<<r<<endl;
  }
}


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

using namespace std;

int main(void){
    int n, tmp;
    int sum = 0;
    vector<int> L;
    cin>>n;
    for(int i=1; i<n+1; i++){
        cin>>tmp;
        L.push_back(tmp);  
    }
    sort(L.begin(), L.end());

    for(int i=0; i<n-1; i++){
        sum += L[i];
    }

    if(sum>L.back()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
from itertools import combinations

N,M=map(int,input().split())

swt=[]
for i in range(M):
    lis=list(map(int,input().split()))
    swt.append(lis)
p=list(map(int,input().split()))
li=list(range(1,N+1))
combi=[]
for i in range(N+1):
    combi.extend(combinations(li,i))

ans=0
for s in combi:
    f=True
    for i in range(M):
        temp=0
        for j in range(1,swt[i][0]+1):
            if  swt[i][j] in s:
                temp+=1
        if not temp%2==p[i]:
            f=False
            break
    if f:
        ans+=1
print(ans)


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

class Union_find{
public:
    std::vector<std::pair<int,int>> data; //各頂点の根を保持する root / size
    long long res;
    Union_find(int n){
        data.resize(n,{-1,1});
        res = (long long)data.size() * ((long long)data.size()-1) / 2;
    }
    //親を見つける
    int root(int i){
        if(data[i].first == -1)return i;
        else return data[i].first = root(data[i].first);
    }
    //頂点iと頂点jの木を統合する
    void unite(int i,int j){
        i = root(i);
        j = root(j);
        if(i != j){
            res -= (long long)data[i].second * data[j].second;
            data[i].first = j; //iの親をjにする
            data[j].second += data[i].second;
        }
    }
};


int main()
{
    int n,m;
    std::cin>>n>>m;
    Union_find un(n);
    std::vector<std::pair<int,int>> hasi(m);
    std::vector<long long> ans(m);
    for(int i=0;i<m;i++){
        std::cin>>hasi[i].first>>hasi[i].second;
        hasi[i].first--;
        hasi[i].second--;
    }
    for(int i=m-1; i >=0 ; i--){
        ans[i] = un.res;
        un.unite(hasi[i].first,hasi[i].second);
    }
    for(int i=0;i<m;i++)std::cout<<ans[i]<<std::endl;

}

Measured memory_bytes: 3712
from collections import defaultdict
import sys

def dfs(visited, graph, grapht, graph2, num, x):
  visited[x] = 1

  for nx in graph[x]:
    if not visited[nx]:
      dfs(visited, graph, grapht, graph2, num, nx)

  t = set()
  if num[x]==1 and len(grapht[x])%2==0:
    for e in grapht[x]:
      graph2[x].add(e)
      t.add(e)
  elif num[x]==-1 and len(grapht[x]) and len(grapht[x])%2==0:
    for e in grapht[x]:
      graph2[x].add(e)
      t.add(e)
    tt = grapht[x].pop()
    graph2[tt].add(x)
    graph2[x].remove(tt)
    num[tt] *= -1
  elif num[x]==1 and len(grapht[x])%2==1:
    for e in grapht[x]:
      graph2[x].add(e)
      t.add(e)
    tt = grapht[x].pop()
    graph2[tt].add(x)
    graph2[x].remove(tt)
    num[tt] *= -1
  else:
    for e in grapht[x]:
      graph2[x].add(e)
      t.add(e)
  for e in t:
    if e in grapht[x]:
      grapht[x].remove(e)
    if x in grapht[e]:
      grapht[e].remove(x)

if __name__ == "__main__":
  sys.setrecursionlimit(1000000)
  input = sys.stdin.readline
  n, m = map(int, input().split())

  if m%2==1:
    print(-1)
    exit()

  graph = defaultdict(set)
  grapht = defaultdict(set)
  for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].add(b)
    graph[b].add(a)
    grapht[a].add(b)
    grapht[b].add(a)

  graph2 = defaultdict(set)
  visited = [0]*n
  num = [1]*n

  dfs(visited, graph, grapht, graph2, num, 0)

  for i in range(n):
    if len(graph2[i])%2==1:
      print(-1)
      exit()

  for i in range(n):
    for e in graph2[i]:
      print(i+1, e+1)

Measured memory_bytes: 178884
#include <iostream>
#include <string>
#include <cmath>

int main() {
    long long int n;
    std::cin >> n;

    for (long long i = std::floor(std::sqrt(n)) + 1; i > 0; i--) {
        if (n % i == 0) {
            std::cout << std::to_string(n/i).length() << std::endl;
            return 0;
        }
    }
    return 0;
}

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


int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int n;
    cin >>n;
    long d = pow(10,9)+7;
    long power = 1;
    for(int i=1;i<=n;i++){
        power = i * power % d;
    }
    cout << power<<endl;
}

Measured memory_bytes: 3608
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
ca = Counter(a)

if 0 in ca and ca[0] == n:
    print("Yes")
elif n % 3 == 0 and 0 in ca and ca[0] == n // 3 and len(ca) == 2:
    print("Yes")
elif n % 3 == 0 and len(ca) == 3:
    values = []
    for c in ca:
        if ca[c] == n // 3:
            values.append(c)
    
    if len(values) != 3:
        print("No")
    else:
        ans = 0
        for k in values:
            ans ^= k
        if ans == 0:
            print("Yes")
        else:
            print("No")
else:
    print("No")

Measured memory_bytes: 60912
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll A, ll B, ll T) {
  cout << T/A * B << endl;
}

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  ll T;
  cin >> T;
  solve(A, B, T);
  return 0;
}


Measured memory_bytes: 256