akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------
int gcd(int a, int b){
  if(a < b) return gcd(b, a);
  int r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
//main
//------------------------------------------
signed main(){
  int N;
  cin >> N;
  VI A(N);
  REP(i, N) cin >> A.at(i);

  int dp[N+10][3];

  SORT(A);

  dp[0][0]=0;
  dp[0][1]=0;
  dp[1][0]=gcd(A.at(0), A.at(1));
  dp[1][1]=max(A.at(0), A.at(1));

  FOR(i, 2, N){
    dp[i][0]=gcd(dp[i-1][0], A.at(i));
    dp[i][1]=max(dp[i-1][0], gcd(dp[i-1][1], A.at(i)));
  }




  int dp2[N+10][3];

  REV(A);

  dp2[0][0]=0;
  dp2[0][1]=0;
  dp2[1][0]=gcd(A.at(0), A.at(1));
  dp2[1][1]=max(A.at(0), A.at(1));

  FOR(i, 2, N){
    dp2[i][0]=gcd(dp2[i-1][0], A.at(i));
    dp2[i][1]=max(dp2[i-1][0], gcd(dp2[i-1][1], A.at(i)));
  }

  cout << max(max(dp[N-1][0], dp[N-1][1]),
   max(dp2[N-1][0], dp2[N-1][1])) << endl;
  return 0;
}


Measured memory_bytes: 5760
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <cstring>
#include <string>
#include <math.h>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repp(i, m, n) for(int i = m; i < (int)n; i++)
#define reps(i, n) for(int i = 1; i <= (int)n; i++)
#define pb push_back
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;

int main()
{
	int a, b, c, x, y;
	cin >> a >> b >> c;
	x=max(a, max(b, c));
	y=a+b+c;
	if(abs(x-y)%2==0) cout << (3*x-y)/2 << endl;
	else cout << (3*(x+1)-y)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
n = input()
a = map(int, raw_input().split())

c = 0
for i in range(n):
    mini = i
    for j in range(i, n):
        if a[j] < a[mini]:
            mini = j
    if a[i] != a[mini]:
        a[i], a[mini] = a[mini], a[i]
        c += 1

print(" ".join(map(str, a)))
print(c)

Measured memory_bytes: 4220
#include <iostream>
#include <cstdio>
#include <fstream>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <unordered_map>
#include <string>

#include <functional>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iterator>
#include <iomanip>

#include <cassert>
#include <random>
#include <chrono>

#include <ccomplex>

using namespace std;

#define ll long long
#define prll pair<ll,ll>
#define m_p make_pair
#define INF (ll)1e18

const ll q = 239017;
const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 13;
const ll N = 2e5 + 100;
const ll M = 100;
const ll L = 26;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define T pair<ll,pair<prll,prll>>

struct cmp
{
	bool operator () (T &a, T &b)
	{
		return a.first > b.first;
	}
};

vector<vector<ll>> mt, ds[4];

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

void $main()
{
	ll n, m, r; cin >> n >> m >> r;
	ll a, b, c, d; cin >> a >> b >> c >> d;
	--a; --b; --c; --d;

	for (ll i = 0; i < 4; ++i)
		ds[i].resize(n);

	mt.resize(n);
	for (ll i = 0; i < n; ++i)
	{
		for (ll j = 0; j < 4; ++j)
			ds[j][i].resize(m);

		mt[i].resize(m);
		string s; cin >> s;
		for (ll j = 0; j < m; ++j)
			mt[i][j] = s[j] == '.';
	}

	for (ll k = 0; k < 4; ++k)
		for (ll i = 0; i < n; ++i)
			for (ll j = 0; j < m; ++j)
				ds[k][i][j] = INF;

	for (ll k = 0; k < 4; ++k)
		ds[k][a][b] = 0;

	priority_queue<T,vector<T>,cmp> qr;
	qr.emplace(0,m_p(m_p(a, b), m_p(0, -1)));

	while (!qr.empty())
	{
		auto u = qr.top();

		ll our = u.first;
		ll i = u.second.first.first;
		ll j = u.second.first.second;
		ll streak = u.second.second.first;
		ll t = u.second.second.second;

		if (streak == r)
		{
			t = -1;
			streak = 0;
		}

		qr.pop();

		for (ll k = 0; k < 4; ++k)
		{
			ll x = i + dx[k];
			ll y = j + dy[k];

			ll strk = streak,cost = our + (!strk);

			if (t == -1 || k == t)
				++strk;
			else
			{
				++cost;
				strk = 1;
			}

			if (x < 0 || y < 0 || x >= n || y >= m || !mt[x][y])continue;

			for (ll p = 0; p < 4; ++p)
			{
				if (p != k || ds[p][x][y]<=cost)continue;

				ds[p][x][y] = cost;
				qr.emplace(cost,m_p(m_p(x, y), m_p(strk, k)));
			}
		}
	}

	ll ans = INF;
	for (ll p = 0; p < 4; ++p)
		ans = min(ans, ds[p][c][d]);

	cout << (ans == INF ? -1 : ans);
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
#else
	//freopen("champions", "r", stdin);
	//freopen("club", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	$main();

	return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  double n, k; std::cin >> n >> k;
  double ans = 0;
  rrep(i, n) {
    int x = i, cnt = 0;
    while (x < k) x*= 2, cnt++;
    ans += 1/n * pow(0.5, cnt);
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())

####
import math
def solve(A,B,H,M):
    # A = hour length, B = min length
    t = 60 * H + M
    # First point is at t % 12*60) / 12*60
    # Second point is at t % 60 ) / 60
    #print("!", t)
    alpha = t % (12 * 60)
    alpha /= (12.0 * 60.0)
    alpha = (0.25 - alpha) % 1.00
    #print("!", alpha)
    alpha *= math.pi * 2

    beta = t % (60)
    beta /= (60.0)
    beta = (0.25 - beta) % 1.00
    #print("!", beta)
    beta *= math.pi * 2

    x1, y1 = A * math.cos(alpha), A * math.sin(alpha)
    x2, y2 = B * math.cos(beta), B * math.sin(beta)
    d = (x2-x1)**2 + (y2-y1)**2
    d = d ** 0.5
    return d

print solve(*rrm())


Measured memory_bytes: 64984
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int mod = 1e9+7;
LL dp[200005];
vector<int> g[200005];
LL inv(LL a, LL b = mod-2){
    LL res = 1;
    while(b){
        if(b%2 == 1) res = res*a%mod;
        a = a*a%mod;
        b/=2;
    }
    return res;
}

int sz[200005], par[200005];
void dfs(int u, int p){
    sz[u] = 1;
    par[u] = p;
    for(int i=0;i<g[u].size();i++){
        int v = g[u][i];
        if(v == p) continue;
        dfs(v, u);
        sz[u] += sz[v];
    }
}

int main(){
    int n, a, b;
    scanf("%d", &n);

    dp[0] = 1;
    for(int i=1;i<=n;i++) dp[i] = dp[i-1]*2%mod;

    LL sum = 1, rev;
    for(int i=2;i<=n;i++){
        scanf("%d%d", &a, &b);
        g[a].push_back(b);
        g[b].push_back(a);
        sum = sum*2%mod;
    }
    rev = inv(sum*2%mod);
    dfs(1, 0);

    LL ans = 0;
    for(int u=1;u<=n;u++){

        LL tot = (sum - 1 + mod)%mod;
        for(int i=0;i<g[u].size();i++){
            int v = g[u][i];
            if(v == par[u]) tot = (tot - (dp[n-sz[u]] - 1 + mod)%mod + mod)%mod;
            else tot = (tot - (dp[sz[v]] - 1 + mod)%mod + mod)%mod;
        }
        ans = (ans + tot*rev)%mod;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 25472
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll N;
vl dist;
vector<vector<pl>> G;
void Dij(ll v){
    dist[v]=0;
    priority_queue<pl> que;
    que.emplace(0,v);
    while(que.size()){
        ll d=que.top().fi,v=que.top().se;
        que.pop();
        for(auto nv:G[v]){
            if(dist[nv.fi]>dist[v]+nv.se){
                dist[nv.fi]=dist[v]+nv.se;
                que.emplace(dist[nv.fi],nv.fi);
            }
        }
    }
}
int main(){
    cin>>N;
    dist=vl(N,INF);
    G=vector<vector<pl>>(N,vector<pl>());
    rep(i,N-1){
        ll a,b,c;cin>>a>>b>>c;
        a--,b--;
        G[a].push_back(mp(b,c));
        G[b].push_back(mp(a,c));
    }
    ll Q,K;cin>>Q>>K;
    Dij(K-1);
    rep(i,Q){
        ll x,y;cin>>x>>y;
        x--,y--;
        cout<<dist[x]+dist[y]<<endl;
    }
    return 0;
}

Measured memory_bytes: 11120
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> wt;
    wt.push_back(1);
    ll tmp=6;
    while(tmp<=N){
        wt.push_back(tmp);
        tmp*=6;
    }
    tmp=9;
    while(tmp<=N){
        wt.push_back(tmp);
        tmp*=9;
    }
    vector<ll> dp(N+10);
    for(int i=0;i<=N;i++){
        dp[i]=1<<30;
    }
    dp[0]=0;
    for(int i=1;i<=N;i++){
        for(int j=0;j<wt.size();j++){
            if(i-wt[j]<0) continue;
            dp[i]=min(dp[i],dp[i-wt[j]]+1);
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
// http://arc084.contest.atcoder.jp/submissions/1737556
    #include <bits/stdc++.h>
    
   using namespace std;
   typedef long long ll;
   typedef unsigned long long llu;
   typedef double lf;
   typedef unsigned int uint;
   typedef long double llf;
   typedef pair<int, int> pii;
   typedef pair<ll, int> pli;
    
   #define debug(format, ...) printf(format, __VA_ARGS__);
    
   const int K_ = int(1e5), B = 50;
    
   int K;
   bool vis[K_][B+1];
    
   int main() {
     scanf("%d", &K);
    
     int ub = 0;
     for(int k = K; k > 0; k /= 10) ub += k % 10;
     
     priority_queue< pii, vector<pii>, greater<pii> > pq;
     pq.emplace(0, 0);
     vis[0][0] = true;
    
     while(!pq.empty()) {
       int s, u; tie(s, u) = pq.top(); pq.pop();
       if(u == 0 && s > 0) {
         printf("%d\n", s);
         return 0;
       }
       for(int d = 0; d < 1; d++) {
         int v = (u * 10 + d) % K;
         int t = s + d;
         if(t <= B && !vis[v][t]) {
           vis[v][t] = true;
           pq.emplace(t, v);
         }
       }
       for(int d = 1; d <= 1; d++) {
        int v = (u +  d) % K;
        int t = s + d;
        if(t <= B && !vis[v][t]) {
          vis[v][t] = true;
          pq.emplace(t, v);
        }
      }

     }
     
     return 0;
   }

Measured memory_bytes: 6392
package main

import (
  "bufio"
  "fmt"
  "os"
  "sort"
  "strconv"
)

//============================================================
var sc = bufio.NewScanner(os.Stdin)

func setScSplit() { sc.Split(bufio.ScanWords) }
func readStr() string {
  sc.Scan()
  return sc.Text()
}
func readInt() int {
  i, _ := strconv.Atoi(readStr())
  return i
}
func readFloat() float64 {
  f, _ := strconv.ParseFloat(readStr(), 64)
  return f
}
func uniq(list []int) []int {
  m := make(map[int]struct{}) // 空のstructを使う
  for _, ele := range list {
    m[ele] = struct{}{} // m["a"] = struct{}{} が二度目は同じものとみなされて重複が消える。
  }
  uni := []int{}
  for i := range m {
    uni = append(uni, i)
  }
  return uni
}
func usort(list []int) []int {
  sort.Sort(sort.IntSlice(list))
  return list
}
func dsort(list []int) []int {
  sort.Sort(sort.Reverse(sort.IntSlice(list)))
  return list
}

//=============================================================

func main() {
  setScSplit()
  n, y := readInt(), readInt()
  a1, a2, a3 := -1, -1, -1
  for i := 0; i <= n; i++ {
    for j := 0; j <= n; j++ {
      k := n - i - j
      if k < 0 {
        continue
      }
      if i*10000+j*5000+k*1000 == y {
        a1, a2, a3 = i, j, k
      }
    }
  }
  fmt.Println(strconv.Itoa(a1) + " " + strconv.Itoa(a2) + " " + strconv.Itoa(a3))
}


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

int main(){
	int n; cin>>n;
	int ans=0;
	rep(i,n){
		int a; cin>>a;
		ans+=a;
	}
	cout<<ans-n<<endl;
}

Measured memory_bytes: 3584
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    int N, i;
    cin >> N >> i;
    int ans = N-i+1;

    cout << ans << endl;
    return 0;
}

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

int execute(int h[], int N);

int main() {
    int N;
    cin >> N;
    int h[N];
    for(int n = 0; n < N; n++){
        cin >> h[n];
    }
    cout << execute(h, N);
}

int execute(int h[], int N){
    int result = 0;
    int s = 0;
    int* p = h;
    for(int i = 0; i < N; i++){
        if(*p == 0) {
            if(s < i){
                result += 1 + execute(h + s, i - s);
            }
            s = i + 1;
        } else {
            --*p;
        }
        p++;
    }
    if(s < N) {
        result += 1 + execute(h + s, N - s);
    }
    return result;
}

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

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

  vector<int>ans(N);
  for(int i=0;i<N;i++){
    ans.at(A.at(i)-1) = i+1;
  }
  for(int i=0;i<N-1;i++){
    cout << ans.at(i) << ' ' ;
  }
  cout << ans.at(N-1) << endl;
}


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

int main()
{
    int N, M, a, b;
    cin >> N >> M;
    vector<pair<int, int>> P(M);
    for (int i = 0; i < M; i++)
    {
        cin >> P[i].first >> P[i].second;
    }
    for (int j = 0; j < 1000; j++)
    {
        int k = 1;
        int Nj = j / 10;
        vector<int> d(1, j % 10);
        while (Nj)
        {
            k++;
            d.push_back(Nj % 10);
            Nj /= 10;
        }
        if (k != N)
            continue;
        bool ok = true;
        reverse(d.begin(), d.end());
        for (int i = 0; i < M; i++)
        {
            if (d[P[i].first - 1] != P[i].second)
                ok = false;
        }
        if (ok)
        {
            cout << j << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

int H,W,N;

void solve()
{
	int ans = 0, stroke = 0;
	if(H >= W){
		while(ans < N){
			stroke++;
			ans += H;
		}
	}else{
		while(ans < N){
			stroke++;
			ans += W;
		}
	}
	cout << stroke << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> H >> W >> N;
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
bitset<N> B;
int n, m, rt, T[N];
int main(){
    fill(T, T+N, 1);
    B.set(1);
    scanf("%d %d", &n, &m);
    for(int i=0;i<m;i++){
        int a, b; scanf("%d %d", &a, &b);
        if(!T[a]) continue;
        if(B[a]) B[b] = 1;
        if(T[a]==1) B[a] = 0;
        T[a]--; T[b]++;
    }
    printf("%d", (int)B.count());
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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 maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    ll N; cin>>N;
    ll ans=0;
    vector<string> S(N);
    rep(i,N) cin>>S[i];
    rep(i,N){
        sort(all(S[i]));
    }
    map<string,ll> m;
    rep(i,N){
        m[S[i]]++;
    }
    
    for(auto x:m){
        ans+=(x.b)*(x.b-1)/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 13960
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

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

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

    int n;
    string s;
    cin >> n >> s;
    vector<vector<int>> S(2, vector<int>(n + 1, 0));
    for(int i = 0; i < n; ++i){
        if(s[i] == 'W') S[0][i + 1] = 1;
        else    S[1][i + 1] = 1;
    }
    for(int i = 0; i < 2; ++i){
        for(int j = 0; j < n; ++j){
            S[i][j + 1] += S[i][j];
        }
    }
    int ans = INF;
    for(int i = 0; i <= n; ++i){
        chmin(ans, S[0][i] + S[1][n] - S[1][i] - min(S[0][i], S[1][n] - S[1][i]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 5980
def examA():
    AB = LI(); AB.sort()
    ans = 0
    if AB[1]==1:
        ans += 400000
    for i in range(2):
        if AB[i]==1:
            ans +=300000
        elif AB[i]==2:
            ans +=200000
        elif AB[i]==3:
            ans +=100000
    print(ans)


def examB():
    return

def examC():
    return

def examD():
    return

def examE():
    return

import sys,copy,bisect,itertools
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 38484
# coding: utf-8
import sys
input = sys.stdin.readline
 
N, M = [int(i) for i in input().split()]
 
plices = [[int(i) for i in input().split()] for _ in range(N)]
 
plices.sort(key = lambda x:x[0])
 
m = 0
cost = 0
 
for i in range(N):
    if m >= M:
        break
    buy = min(M - m, plices[i][1])
    cost += plices[i][0] * buy
    m += buy
 
print(cost)

Measured memory_bytes: 22800
list=[int(input()) for i in range(20)]
W=[]
for j in range(10):
    W.append(list[j])
K=[]
for n in range(10,20):
    K.append(list[n])
w=sorted(W)
k=sorted(K)
wsum=0
ksum=0
for m in range(7,10):
    wsum+=int(w[m])
    ksum+=int(k[m])
print(wsum,ksum)


Measured memory_bytes: 5604
import math
def facts(n):
    ans = []
    for  i in range(1, int(math.sqrt(n)+1)):
        if(n%i==0):
            ans.append(i)
            ans.append(n//i)
    ans = sorted(list(dict.fromkeys(ans)))
    if(ans[-1]==n):
        ans = ans[:-1]
    return ans
h,w,k = map(int, input().split())
grid =[]
ans = 0
for i in range(h):
    grid.append(list(input()))
for mask1 in range(2**(h)):
    for mask2 in range(2**w):
        count = 0
        for r in range(h):
            for c in range(w):
                if(grid[r][c]!= '#'):
                    continue
                elif(((mask1>>r)&1) or((mask2>>c)&1)):
                    continue
                else:
                    count+=1
        if(count==k):
            ans+=1
print(ans)

Measured memory_bytes: 68468
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]"):
    from itertools import groupby
    S = sorted(S)
    t = [(len(list(v)), k) for k, v in groupby(S)]
    n = max(tt[0] for tt in t)
    return sorted([k for _, k in filter(lambda tt: tt[0] == n, t)])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    print(*solve(N, S), sep='\n')

if __name__ == '__main__':
    main()


Measured memory_bytes: 37496
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
using ll=long long int;
using ppi=pair<ll,ll>;
using pql =priority_queue<ll, vector<ll>, greater<ll>>;
using pq=priority_queue<ll>;

int main()
{
    int n;
    cin>>n;
    if(n<3){
        cout<<0<<endl;
        return 0;
    }
    string s;
    cin>>s;
    vector<int>a(n);
    ll r=0;
    ll g=0;
    ll b=0;

    rep(i,n){
        if(s[i]=='R'){
            a[i]=0;
            r++;
        }else if(s[i]=='G'){
            a[i]=1;
            g++;
        }else {
            a[i]=4;
            b++;
        }
    }
    ll c=0;
    rep(i,n){
        rep2(j,i+1,n){
            if(2*(j+1)-(i+1)>n){
                break;
            }
            if(a[i]+a[j]+a[2*j-i]==5){
                c++;
            }
        }
    }
    cout<<r*g*b-c<<endl;
    

    return 0;
}

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

using namespace std;

#define fastio ios::sync_with_stdio(0);cin.tie(0);
typedef long long ll;

int main()
{
	#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin); 
	freopen("output.txt", "w", stdout); 
	#endif	
	
	fastio;

	int n;
	cin >> n;

	ll arr[n], total = 0;

	for(int i = 0; i < n; i++)
	{	
		cin >> arr[i];
		if(i > 0 && arr[i] < arr[i - 1])
		{
			total += arr[i-1] - arr[i];
			arr[i] = arr[i - 1];
		}
	}

	cout << total;

	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> A(N-1);
    vector<int> B(N);
    for(int i =0; i < N-1; i++){
        A.at(i) = 0;
        B.at(i) = 0;
        cin >> A.at(i);
        B.at(A.at(i)-1) += 1;
    }
    for(int i =0; i< N; i++){
        cout << B.at(i) << endl;
    }
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N,M;
  cin >> N >> M;
  map<int, bool> m;
  m[0] = true;
  vector<int> v(N,1);

  for(int i = 0; i < M; i++){
    int tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    tmp1--;
    tmp2--;
    v.at(tmp1)--;
    v.at(tmp2)++;

    if(m.count(tmp1) != 0){
      // xがあるかもしれないところが選ばれていた場合
      if(v.at(tmp1) == 0){
        m.erase(tmp1);
      }
      m[tmp2] = true;
    }
  }

  cout << m.size() << endl;
}


Measured memory_bytes: 5376
import math

X = int(input())


def isPrime(n):
    if n == 2:
        return True
    if n % 2 == 0:
        return False

    # nの平方根まで計算する
    m = math.floor(math.sqrt(n)) + 1
    for p in range(3, m, 2):
        if n % p == 0:
            return False
    return True


a = isPrime(X)

while a is False:
    X += 1
    a = isPrime(X)
else:
    print(X)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int n;
    cin>>n;

    n--;
    vector<int>res;
    while(n>=0){
    	res.pb(n%26);
    	n = floor(n/26.0)-1;
    }
    reverse(all(res));
    for(int x : res) cout<<char('a'+x);
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  ll n,k;
  cin >>n>>k;
  vector<ll> P(n,0);
  ll tmp = 0;
  rep(i,n){
    ll x;
    cin >>x;
    x ++;
    tmp += x;
    P[i] = tmp;
  }
  vector<ll> sums(n-k+1,0);
  ll ans = 0;
  rep(i,n-k+1){
    if(i) sums[i] = P[i+k-1] - P[i-1];
    else sums[i] = P[i+k-1];
    ans = max(ans,sums[i]);
  }
  if (ans%2 == 0) cout << ans/2;
  else cout << fixed << setprecision(10) << 0.5+ans/2;
  cout << endl;
}

Measured memory_bytes: 3328
i = 2
n = int(input())
n_ = n

ans = []

while i*i <= n:
    while n % i == 0:
        ans.append(i)
        n //= i
    i += 1

if n > 1:
    ans.append(n)

print(str(n_) + ': ' + ' '.join([str(i) for i in ans]))




Measured memory_bytes: 5608
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
   
 #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
 #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n,p;
   cin>>n>>p;
   string s;
   cin>>s;
   if(p==2)
   {
      int ans=0;
      for(int i=0;i<n;i++)
      {
         if((s[i]-'0')%2==0)
         {
            ans+=i+1;
         }
      }
      cout<<ans;
      return 0;
   }
   else if(p==5)
   {
      int ans=0;
      for(int i=0;i<n;i++)
      {
         if((s[i]-'0')%5==0)
         {
            ans+=i+1;
         }
      }
      cout<<ans;
      return 0;
   }

   int mm[10005]={0};
   mm[0]=1;
   int cur=0,pp=1;
   int ans=0;
   for(int i=n-1;i>=0;i--)
   {
      cur=(cur+pp*(s[i]-'0'))%p;
      pp=(pp*10)%p;
      ans+=mm[cur];
      mm[cur]++;
   }
   cout<<ans;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }
 

Measured memory_bytes: 720
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back 
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int> 
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second 
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key

//const int32_t mod=163577857; const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0); const int32_t mod=998244353; 
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;

void solve(){
    char a;
    cin>>a;
    int n=a-'a';
    if(n>=0) cout<<'a';
    else cout<<'A';
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;                                                                                                                  
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 3656
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main(){
	int k, n;
	cin >> k >> n;
	vi a(n), b(n);
  	ll sum = 0;
	rep(i,n) {
      	cin >> a[i];
    }
  	rep(i,n-1){
    	b[i] = a[i+1]-a[i];
    }
  	b[n-1] = a[0] + k - a[n-1];
  	sort(rall(b));
  	cout << k - b[0] << endl;
	return;
}

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
// Binary Indexed Tree 2D
template <class Abel> struct BIT2D {
    const Abel UNITY_SUM = 0; // to be set
    vector<vector<Abel>> dat;

    BIT2D(int n = 1, int m = 1) : dat(n + 1, vector<Abel>(m + 1, UNITY_SUM)) {}
    void init(int n, int m) {
        dat.assign(n + 1, vector<Abel>(m + 1, UNITY_SUM));
    }

    /* add x on the point (a, b) */
    inline void add(int a, int b, Abel x) {
        for (int i = a; i < (int)dat.size(); i += i & -i)
            for (int j = b; j < (int)dat[0].size(); j += j & -j)
                dat[i][j] = dat[i][j] + x;
    }

    inline Abel sum(int p, int q) {
        Abel res = UNITY_SUM;
        for (int i = p; i > 0; i -= i & -i)
            for (int j = q; j > 0; j -= j & -j)
                res = res + dat[i][j];
        return res;
    }

    /* a1 <= x < b1, a2 <= y < b2, 1-indexd */
    inline Abel sum(int a1, int a2, int b1, int b2) {
        return sum(b1 - 1, b2 - 1) - sum(a1 - 1, b2 - 1) - sum(b1 - 1, a2 - 1) +
               sum(a1 - 1, a2 - 1);
    }

    /* debug */
    void print() {
        for (int i = 1; i < (int)dat.size(); ++i) {
            for (int j = 1; j < (int)dat[0].size(); ++j)
                cout << sum(i, j, i + 1, j + 1) << ",";
            cout << "¥n";
        }
    }
};

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

    int N, M, Q;
    cin >> N >> M >> Q;
    BIT2D<int> bt(N, N);
    REP(i, M) {
        int l, r;
        cin >> l >> r;
        bt.add(l, r, 1);
    }
    REP(i, Q) {
        int p, q;
        cin >> p >> q;
        cout << bt.sum(p, p, q + 1, q + 1) << "\n";
    }

    return 0;
}


Measured memory_bytes: 4228
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nx = Console.ReadLine().Split().Select(int.Parse).ToArray();
        long X = nx[1];
        //ちゅーごくじょーよてーり
        //オーダーによってSの終端が決定する
        //まず影響するのは降順のみなことは自明に分かって、
        //で、「次」を選ぶことができる順番は
        //「確率」「期待値」
        //aを取り除いた場合、その後に適用できるのはそれ以前全て。

        List<int> s = Console.ReadLine().Split().Select(int.Parse).OrderByDescending(x => x).ToList();
        ModInt[] dp = new ModInt[X + 1];
        dp[X] = 1;
        long remain = s.Count - 1;
        foreach (var mod in s)
        {
            ModInt[] newDP = new ModInt[X + 1];

            for (int i = 0; i < dp.Length; i++)
            {
                newDP[i % mod] += dp[i];
                newDP[i] += dp[i] * remain;
            }
            remain--;
            dp = newDP;
        }
        ModInt res = 0;
        for (int i = 0; i < dp.Length; i++)
        {
            res += dp[i] * i;
        }
        Console.WriteLine(res);
    }
}

struct ModInt
{
    const int MOD = 1000000007;
    long Data;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public ModInt(long data) { if ((Data = data % MOD) < 0) Data += MOD; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator long(ModInt modInt) => modInt.Data;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static implicit operator ModInt(long val) => new ModInt(val);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt a, ModInt b)
    {
        long res = a.Data + b.Data;
        return new ModInt() { Data = res >= MOD ? res - MOD : res };
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator +(ModInt a, long b) => new ModInt(a.Data + b);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt a, ModInt b)
    {
        long res = a.Data - b.Data;
        return new ModInt() { Data = res < 0 ? res + MOD : res };
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator -(ModInt a, long b) => new ModInt(a.Data - b);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static ModInt operator /(ModInt a, ModInt b) => a * Power(b, MOD - 2);

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static ModInt Power(ModInt n, long m)
    {
        ModInt res = 1;
        while (m > 0)
        {
            if ((m & 1) == 1) res *= n;
            n *= n;
            m >>= 1;
        }
        return res;
    }
}


Measured memory_bytes: 30080
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    itn n;
    cin >> n;
    lint ans = 0;
    vector<vector<int>> a(n,vector<int>(n));
    vector<vector<int>> b(n,vector<int>(n));
    bool flag = true;
    REP(i,n){
        REP(j,n) cin >> a[i][j];
    }
    copy(ALL(a),b.begin());
    REP(i,n){
        REP(j,n){
            REP(k,n){
               b[j][k] = min(b[j][k], b[j][i] + b[i][k]); 
            }
        }
    }
    REP(i,n){
        REP(j,n){
            ans += a[i][j];
            if(b[i][j] != a[i][j]){
                flag = false;
                break;
            }
            if(b[i][j] == a[i][j]){
                REP(k,n){
                    if(i == k || j == k) continue;
                    if(b[i][j] == b[i][k] + b[k][j]){
                        ans -= a[i][j];
                        break;
                    }
                }
            }
        }
    }
    if(flag) println(ans/2); else println(-1);
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
    }
    
    Scanner sc;
    int a;
    int b;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        a = sc.nextInt();
        b = sc.nextInt();
    }
    
    //解答処理
    int solve() {
        int x = 0;  //雪の積もった高さ
        //int towerB = 0
      
        x = (b-a) * (b-a+1) / 2 -b;
        return x;
    }
    
    //出力
    void show(int answer) {
        System.out.println(answer);
    }
}


Measured memory_bytes: 35808
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	int x,i=1;
	while (cin >> x)
	{
		if (x == 0) break;
		cout << "Case " << i << ": " << x << endl;
		i++;
	}
	return 0;
}

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

struct Edge{
    int from,to;
    int dist;
    int cost;
};

bool operator<(Edge lhs,Edge rhs){
    return lhs.cost>rhs.cost;
}
using Graph=vector<vector<Edge>>;
int ans=0;
using ll=long long;
const ll W=1e9;
vector<ll> Dijkstra(int s,const Graph& g){
    priority_queue<pair<ll,pair<int,int>>,vector<pair<ll,pair<int,int>>>,greater<>> que;

    que.push({0,{s,0}});
    vector<ll> res(g.size(),1e17);
    res[0]=0;
    
    while(!que.empty()){
        if(que.size()>=1e7) throw "HELLO";
        auto tmp=que.top(); que.pop();
        int v=tmp.second.first;
        if(res[v]<tmp.first) continue;
        ans+=tmp.second.second;
        for(auto &e:g[v]){
            if(res[e.to]>res[v]/W*W+W*e.dist+e.cost){
                res[e.to]=res[v]/W*W+W*e.dist+e.cost;
                que.push({res[e.to],{e.to,e.cost}});
            }
        }
    }
    return res;
}
int solve(int n,int m){
    Graph g(n);
    for(int i=0;i<m;i++){
        int u,v,d,c;
        cin>>u>>v>>d>>c;
        u--,v--;
        g[u].push_back(Edge{u,v,d,c});
        g[v].push_back(Edge{v,u,d,c});
    }
    ans=0;
    vector<ll> d=Dijkstra(0,g);
    return ans;
}
int main(){
    int n,m;
    while(cin>>n>>m,n){
        cout<<solve(n,m)<<endl;
        
    }
    return 0;
}


Measured memory_bytes: 4396
/*input
0 0 10 0 0 0 0
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX 
#define INF 0x3f3f3f3f

int i , o , t , j , l , s , z , ans;
int32_t main(){
    IOS;
    cin >> i >> o >> t >> j >> l >> s >> z;
    ans = o * 2 , o = 0;
    int v1 = (i / 2 * 4) + (j / 2 * 4) + (l / 2 * 4);
    int v2 = -1;
    if(i && j && l){
        i -- , j -- , l --;
        v2 = 6 + (i / 2 * 4) + (j / 2 * 4) + (l / 2 * 4);
    }
    cout << max(v1 + ans , v2 + ans) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	int N; cin >> N;
	string s; cin >> s;
	vector<int>black(N, 0), white(N, 0);
	rep(i, 0, N) {
		if (s[i] == '#')black[i]++;
		else white[i]++;
	}
	rep(i, 1, N) {
		black[i] += black[i - 1];
		white[i] += white[i - 1];
	}
	int ans = min(black[N - 1], white[N - 1]);
	rep(i, 1, N) {
		chmin(ans, black[i - 1] + white[N - 1] - white[i - 1]);
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 2196
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>

using namespace std;

int main(){
    int x,y;
    cin >> x >> y;

    cout << x + (y/2) << endl;
    return 0;
}





Measured memory_bytes: 256
import java.util.*;

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

        int N = scanner.nextInt();
        HashMap<Integer, Integer> hashMap = new HashMap<>();

        for(int i=0; i<N; i++){
            int num = scanner.nextInt();
            if(hashMap.containsKey(num)){
                int tmp = hashMap.get(num);
                tmp++;
                hashMap.put(num, tmp);
            }else{
                hashMap.put(num, 1);
            }
        }

        int cnt = 0;

        for(int key: hashMap.keySet()){
            int tmp = hashMap.get(key);
            if(tmp < key){
                cnt += tmp;
            }else{
                cnt += tmp - key;
            }
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 61320
e1, e2, e3, e4 = map(int,input().split())

if e1 == e2:
    if e3 == e4:
        print('yes')
    else:
        print('no')
elif e1 == e3:
    if e2 == e4:
        print('yes')
    else:
        print('no')
elif e1 == e4:
    if e2 == e3:
        print('yes')
    else:
        print('no')
else:
    print('no')



Measured memory_bytes: 5596
//
//
//  a.cpp - created by yugo
//
#include <iostream>
using namespace std;

int main(int argc, char *argv[]){
  int n[3];
  int c=0;
  for(int i=0; i<3; i++)
    cin >> n[i];
  for(int i=0; i<2; i++)
    for(int j=i+1; j<3; j++)
      if(n[i]==n[j])
	c++;
  if(c==1)
    cout << "Yes\n";
  else
    cout << "No\n"; 
}


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

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

ll dp[1000005][2];

int main() {
	string n;
	cin >> n;
	ll l = n.size();
	dp[0][0] = n[0] - '0';
	dp[0][1] = 11 - (n[0] - '0');
	REP(i, l - 1) {
		int d = n[i] - '0';
		dp[i][0] = min(dp[i-1][0] + d, dp[i-1][1] + d);
		dp[i][1] = min(dp[i-1][0] + 11 - d, dp[i-1][1] + 9 - d);
	}
	ll ans = min(dp[l-1][0], dp[l-1][1]);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 17028
import sys
input = sys.stdin.readline

lA, lB, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
XYZ = [list(map(int, input().split())) for _ in range(M)]

ans = min(A) + min(B)
dic = {}
for x, y, c in XYZ:
    ans = min(ans, A[x-1]+B[y-1]-c)

print(ans)

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

#define dbg(a)  cerr << __LINE__ << ": " << #a << " = " << a << '\n'

typedef long long ll;

int main(){
  ll x; cin >> x;
  ll amount = 100;
  for (int i = 1; ; ++i){
    amount  = amount + (0.01*amount);
    if(amount >= x){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3632