akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define     ll          long long int
#define     ld          double
#define     REP(i,x,n)    for(ll i=x;i<n;i++)
#define     SZ(v)       (ll)v.size()
#define     endl        "\n"
#define     ff          first
#define     ss          second
#define     PQ_MIN      priority_queue <ll, vector<ll>, greater<ll> >
#define     PQ          priority_queue <int>
#define     pbds        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define     setbit(x)   __builtin_popcount(x)
#define     prec(n)     fixed<<setprecision(n)
#define     pb(n)       push_back(n)
#define     mp(a,b)     make_pair(a,b)
#define     clr(n)      memset(n,0,sizeof(n))
#define     reset(n)    memset(n,-1,sizeof(n))
#define     ii          pair<ll,ll>
#define     vll         vector<ll>
#define     PI          3.1415926535897932384626433832795028841971693993751

using namespace std;
using namespace __gnu_pbds;
bool comp(pair<ll,ll> a,pair<ll,ll> b) {       }
const ll MOD=1e9+7;
void print(vector<vector<ll> >&v)
{
    ll n=v.size();
    ll m=v[0].size();
    cout<<"\n";
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
            cout<<v[i][j]<<" ";
        cout<<"\n";
    }
}
void print(vector<ll>&v)
{
    ll n=v.size();
    cout<<"\n";
    for(ll i=0;i<n;i++)
    {
            cout<<v[i]<<" ";
    }
        cout<<"\n";

}
void print(set<ll>&s)
{

cout<<endl;

set<ll>::iterator it;
for(it=s.begin();it!=s.end();it++)
    cout<<*it<<" ";
cout<<endl;
}
ll __lcm(ll a,ll b)
{
    return ((a*b)/__gcd(a,b));
}
ll power(ll a,ll p)
{
    ll res=1;
    while(p>0)
    {
        if(p&1){
            res=(res*a)%MOD;
            p--;
        }
            a=(a*a)%MOD;
            p/=2;
    }

    return res%MOD;
}
const ll INF=1e16;
const ll nxm=1e5+5;
void solve(){
ll n;
cin>>n;
ll ans=-INF;
pair<ll,ll> point[n];

REP(i,0,n)
cin>>point[i].ff>>point[i].ss;

sort(point,point+n);

ll maxi=point[0].ss-point[0].ff,mini=point[0].ff+point[0].ss;

for(ll i=1;i<n;i++)
{
    ans=max(ans,(point[i].ff+point[i].ss)-mini);
    ans=max(ans,point[i].ff-point[i].ss+maxi);
    maxi=max(maxi,point[i].ss-point[i].ff);
    mini=min(mini,point[i].ff+point[i].ss);
}

cout<<ans<<endl;








}
int main(){
//    freopen("timber_input", "r", stdin);
//    freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin>>t;
    REP(i,1,t+1)
    {
//    cout<<"Case #"<<i<<": ";
		solve();
    }
	return 0;
}
//  bitset<64>(x).to_ullong() // in my com  _ulong()
//  cout<<bitset<64>(ans).to_string().substr(64-m)<<endl;
/*

const int INF = 0x3f3f3f3f;


char s[100];

fgets(s,100,stdin);

stringstream stram(s);

string abc;

bool ok1=0,ok2=0;

while(stram>>abc)

ternary operator for(int i=0;i<23;i++) or while(r-l>eps)

struct P
{

    double logp;
    ll p;
    ll ind;

    	bool operator<(const P &p) const {
		if (abs(logp - p.logp) > 1e-7)
			return logp < p.logp;

		return ind < p.ind;
	} /// to use in set
};

*/


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

using namespace std;

template <class T>
struct edge {
    size_t to;
    T cost;
    edge(size_t to, T cost = 1) : to(to), cost(cost) {}
};

template <class T>
class graph {
private:
    const size_t count_nodes;
    const bool is_directed;
public:
    vector<edge<T>> *edges;
    graph(size_t count_nodes, bool is_directed = true) : count_nodes(count_nodes), is_directed(is_directed) {
        edges = new vector<edge<T>>[count_nodes];
    }
    ~graph() {
        delete [] edges;
    }
    size_t size() const { return count_nodes; }
    void make_edge(size_t u, size_t v, T cost) {
        edges[u].push_back(edge<T>(v, cost));
        if (!is_directed)
            edges[v].push_back(edge<T>(u, cost));
    }
};

template <class T>
vector<T> dijkstra(const graph<T> &g, const int start) {
    vector<T> dist(g.size());
    bool *used = new bool[g.size()]();
    priority_queue<pair<T, size_t>, vector<pair<T, size_t>>, greater<pair<T, size_t>>> q;
    dist[start] = 0;
    q.push(pair<T, size_t>(dist[start], start));
    used[start] = true;
    while (!q.empty()) {
        T dist_v;
        size_t v;
        tie(dist_v, v) = q.top();
        q.pop();
        if (dist[v] < dist_v)
            continue;
        for (edge<T> e: g.edges[v]) {
            size_t w = e.to;
            T dist_v_w = dist_v + e.cost;
            if (!used[w] || dist[w] > dist_v_w) {
                dist[w] = dist_v_w;
                q.push(pair<T, size_t>(dist[w], w));
                used[w] = true;
            }
        }
    }
    delete [] used;
    return dist;
}

template <class T>
T diameter_of_tree(const graph<T> &g) {
    size_t n = g.size();
    vector<T> dist_from_0 = dijkstra(g, 0);
    size_t v = 0;
    T dist_from_0_max = 0;
    for (size_t w = 1; w < n; ++w) {
        if (dist_from_0_max < dist_from_0[w]) {
            dist_from_0_max = dist_from_0[w];
            v = w;
        }
    }
    vector<T> dist_from_v = dijkstra(g, v);
    return *max_element(dist_from_v.begin(), dist_from_v.end());
}

int main(void) {
    int n;
    cin >> n;
    graph<int> g(n, false);
    for (int i = 0; i < n - 1; ++i) {
        int s, t, w;
        cin >> s >> t >> w;
        g.make_edge(s, t, w);
    }
    cout << diameter_of_tree(g) << endl;
    return 0;
}


Measured memory_bytes: 11820
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
int m;
cin>>m;
ll sum=0,t=0;
for(int i=0;i<m;i++){
    ll d,c;
    cin>>d>>c;
    t+=c;
    sum+=d*c;
}
//(桁の数分の操作)+(繰り上がりの回数)
ll ans=t-1+(sum-1)/9;
cout<<ans<<endl;
}


Measured memory_bytes: 256
/*! if g++ -g alds_1_4_a.cpp -o alds_1_4_a.out; then ./alds_1_4_a.out < alds_1_4_a.test; fi
 */

#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <numeric>
#include <functional>
#include <climits>



using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main(int argc, char *argv[]){
  int n;
  cin >> n;
  vector<int> s(n);
  for (size_t i = 0; i < n; i++) {
    cin >> s[i];
  }
  int m;
  cin >> m;
  int ret = 0;
  for (size_t i = 0; i < m; i++) {
    int t;
    cin >> t;
    for (size_t j = 0; j < n; j++) {
      if(t == s[j]){
        ret++;
        break;
      }
    }
  }
  cout << ret << endl;



  return 0;
}

Measured memory_bytes: 1232
# 頂点 v の所属するグループを調べる
def root(v, uni):
  if uni[v] < 0:  # v が親の場合
    return v
  else:           # v が子の場合
    uni[v] = root(uni[v], uni)  # 親のrootを調べる
    return uni[v]

# 頂点 a と頂点 b をつなぐ。もともと同じグループのとき、False を返す
def connect(a, b, uni):
  # まずはそれぞれ根の番号に置き換える
  ra = root(a, uni)
  rb = root(b, uni)
  if ra == rb:  # a と b がそもそも同じグループに属しているなら即終了
    return False
	
  # ra を大きなグループにしたいので、逆であれば入れ替える
  if uni[ra] > uni[rb]: # rbの方が要素数が多ければ
    tmp = ra
    ra  = rb 
    rb  = tmp

  # ra と rb を結合し、rb の親を ra とする
  uni[ra] += uni[rb]
  uni[rb] = ra
  return True
      
##
N, K, L = map(int, input().split())

road = [-1]*(N+1)
rail = [-1]*(N+1)

for i in range(K):
  a, b = map(int, input().split())
  connect(a, b, road)

for i in range(L):
  a, b = map(int, input().split())
  connect(a, b, rail)


##
dp = [0]*(N+1)
for i in range(1, N+1):
  dp[i] = (root(i, road), root(i, rail))

dic = {}
for i in range(1, N+1):
  key = dp[i]
  if key not in dic:
    dic[key] = 1
  else:
    dic[key] += 1

for i in range(1, N+1):
  ans = dic[dp[i]]
  if i == N:
    print(ans)
  else:
    print(ans, end=" ")


Measured memory_bytes: 107636
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int cnt_1=0;
		char char_1='0';
		int cnt_2=0;
		char char_2='0';
		for (int i=0;i<4;i++) {
			if (i==0) {
				char_1=S.charAt(i);
				cnt_1++;
			} else {
				if (S.charAt(i)==char_1) {
					cnt_1++;
				} else {
					if (char_2=='0') {
						char_2=S.charAt(i);
						cnt_2++;
					} else {
						if (S.charAt(i)!=char_2) {
							break;
						} else {
							cnt_2++;
						}
					}
				}
			}
		}
		if (cnt_1==2 && cnt_2==2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

using namespace std;
using i64 = std::int_fast64_t;

struct edge {
  int from;
  int to;
  std::int_fast64_t cost;
};

const i64 INF = 1LL << 58;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<edge> graph(M);
  for (int i = 0; i < M; i++) {
    int a, b;
    i64 c;
    cin >> a >> b >> c;
    a--, b--;
    edge e = {a, b, c};
    graph[i] = e;
  }

  vector<i64> d(N, -INF);
  d[0] = 0;

  for (int i = 0; i < N; i++) {
    for (auto e : graph) {
      if (d[e.from] != -INF) chmax(d[e.to], d[e.from] + e.cost);
    }
  }
  i64 res = d[N - 1];
  for (int i = 0; i < N; i++) {
    for (auto e : graph) {
      if (d[e.from] != -INF) chmax(d[e.to], d[e.from] + e.cost);
    }
  }

  if (res < d[N - 1]) {
    cout << "inf" << '\n';
  } else {
    cout << res << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, a, b;

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

    if (a > b) {
        cout << 0 << endl;
        return 0;
    }

    llong maxv = b * (n - 1) + a;
    llong minv = a * (n - 1) + b;

    cout << max(0ll, maxv - minv + 1) << endl;

    return 0;
}


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


int main() {
    int N;
    cin >>N;
    vector<int>c(N);
    vector<int>v(N);
    rep(i,N)cin>>c[i];
    rep(i,N)cin>>v[i];

    int ans =0;
    rep(i,N){
        if(c[i]-v[i]>0)ans+=c[i]-v[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, M;
map<pair<int, int>, int> stnid;
int idlast;
vector<pair<int, int> > graph[606060];
bool vis[606060];

void ae(int p, int q, int c, int d)
{
	graph[p].push_back({ q, c });
	graph[q].push_back({ p, d });
}

int getid(int stn, int cmp)
{
	if (stnid.count({ stn, cmp })) return stnid[{stn, cmp}];
	int ret = idlast++;
	ae(stn, ret, 1, 0);
	return stnid[{stn, cmp}] = ret;
}

int main()
{
	scanf("%d%d", &N, &M);
	idlast = N;
	for (int i = 0; i < M; ++i) {
		int p, q, c;
		scanf("%d%d%d", &p, &q, &c);
		--p; --q;

		int a = getid(p, c);
		int b = getid(q, c);
		ae(a, b, 0, 0);
	}

	priority_queue<pair<int, int> > Q;
	for (int i = 0; i < idlast; ++i) vis[i] = false;
	Q.push({ 0, 0 });
	while (!Q.empty()) {
		pair<int, int> tmp = Q.top(); Q.pop();
		int cost = -tmp.first;
		int pt = tmp.second;
		if (vis[pt]) continue;
		vis[pt] = true;
		if (pt == N - 1) {
			printf("%d\n", cost);
			return 0;
		}
		for (auto e : graph[pt]) {
			Q.push({ -(cost + e.second), e.first });
		}
	}
	puts("-1");
	return 0;
}


Measured memory_bytes: 60152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second

using namespace std;

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

int main(){
	int n, m;
	while (cin >> n >> m, n | m){
		vector<P> v(m);
		rep(i, m) v[i].second = -i - 1;
		rep(i, n) rep(j, m){
			int x;
			cin >> x;
			v[j].first += x;
		}
		sort(REV(v));

		rep(i, m) cout << (i ? " " : "") << -v[i].second;
		cout << endl;
	}

	return 0;
}

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

vector<int> p;

int main() {
	int n, l, sum = 0, mn = 1e9, res = 0;
	cin >> n >> l;
	p = vector<int>(n);
	for(int i = 1; i <= n; i++) {
		p[i - 1] = l + i - 1;
		sum += p[i - 1];
	}
	for(int i = 0; i < n; i++){
		if(mn > abs(sum - (sum - p[i]))){
			mn = abs(abs(sum - (sum - p[i])));
			res = sum - p[i];
		}
	}
	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
string s="CODEFESTIVAL2016";
string a;
long long ans=0;
int main(){
    cin>>a;
    if(a[0] != 'C') ans++;
    if(a[1] != 'O') ans++;
    if(a[2] != 'D') ans++;
    if(a[3] != 'E') ans++;
    if(a[4] != 'F') ans++;
    if(a[5] != 'E') ans++;
    if(a[6] != 'S') ans++;
    if(a[7] != 'T') ans++;
    if(a[8] != 'I') ans++;
    if(a[9] != 'V') ans++;
    if(a[10] != 'A') ans++;
    if(a[11] != 'L') ans++;
    if(a[12] != '2') ans++;
    if(a[13] != '0') ans++;
    if(a[14] != '1') ans++;
    if(a[15] != '6') ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N,Y = map(int, input().split())
ans_10000= -1
ans_5000 = -1
ans_1000 = -1
for i in range(N+1):
    for j in range(N-i+1):
        if 10000*i+5000*j+1000*(N-i-j) == Y:
            ans_10000= i
            ans_5000 = j
            ans_1000 = N-i-j
            break
print(ans_10000, ans_5000, ans_1000)

Measured memory_bytes: 9084
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
   int N;
   cin >> N;
   int ans = 0;
   for (int i = 1; i <= N; i++)
   {
      int num = i;
      int cnt = 0;
      while(num > 0)
      {
         num /= 10;
         cnt++;
      }
      if(cnt%2 == 1)
      {
         ans++;
      }
   }
   cout << ans << endl;
   return 0;
}


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

int h, w, n;

const int dx[] = { 1, 0 };
const int dy[] = { 0, 1 };

bool judge(vector<vector<int>> a) {
	int cnt;
	do {
		for (int i = 0; i < w; i++) {
			for (int j = h - 1, k = h - 1; j >= 0; j--) {
				if (a[j][i]) {
					if (j != k) swap(a[j][i], a[k][i]);
					k--;
				}
			}
		}
		vector<vector<bool>> flag(h, vector<bool>(w));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i][j]) {
					for (int d = 0; d < 2; d++) {
						int x = i, y = j;
						for (int k = 1;; k++) {
							x += dx[d];
							y += dy[d];
							if (x < 0 || x >= h || y < 0 || y >= w || a[x][y] != a[i][j]) {
								if (k >= n) {
									for (int tx = i, ty = j; tx != x || ty != y; tx += dx[d], ty += dy[d]) {
										flag[tx][ty] = true;
									}
								}
								break;
							}
						}
					}
				}
			}
		}
		cnt = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (flag[i][j]) {
					a[i][j] = 0;
					cnt++;
				}
			}
		}
	} while (cnt);
	bool res = true;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if(a[i][j]) res = false;
		}
	}
	return res;
}

int main()
{
	char c;
	cin >> h >> w >> n;
	vector<vector<int>> a(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> c;
			if (c != '.') {
				a[i][j] = c - 'A' + 1;
			}
		}
	}
	bool res = false;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w - 1; j++) {
			if (a[i][j] != a[i][j + 1] && !res) {
				swap(a[i][j], a[i][j + 1]);
				if (judge(a)) {
					res = true;
				}
				swap(a[i][j], a[i][j + 1]);
			}
		}
	}
	cout << (res ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 3168
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f

#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
int a,b,c;

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    cin>>a>>b>>c;
    if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b))
        cout<<"Yes";
    else
        cout<<"No";    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int[] que = new int[N];
		int[] ans = new int[N];
		
		for (int i = 1 ; i <= N ; i++) {
			ans[sc.nextInt()-1] = i; 
		}
		
		for (int i = 0 ; i < N ; i++) {
			System.out.print(ans[i] + " ");
		}
	}

}


Measured memory_bytes: 61180
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
//#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//struct edge {int to,cost;};

int n;
string s;
bool rullonz = false;

int a[114514] = {};

bool isOK(){
    bool ret = true;
    REP(i,n){
        if(s[i]=='o'&&a[i] || s[i]=='x'&&!a[i]) {if(a[(i+n-1)%n]!=a[(i+1)%n]) ret = false;}
        else {if(a[(i+n-1)%n]==a[(i+1)%n]) ret = false;}
    }
    return ret;
}
 
void output(){
    REP(i,n) putchar(a[i]?'S':'W');
    puts("");
}

signed main(){
    cin >> n >> s;
    REP(i,8){
        a[0] = (i>>0)&1;
        a[1] = (i>>1)&1;
        a[n-1] = (i>>2)&1;
        FOR(i,2,n-1){
            if (s[i-1]=='o') a[i] = a[i-1]?a[i-2]:abs(1-a[i-2]);
            else a[i] = !a[i-1]?a[i-2]:abs(1-a[i-2]);
        }
        if(isOK()){
            output();
            return 0;
        }
    }
    puts("-1");
    return 0;
}



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

stack<char>st;
string s;

main()
{

  cin >> s;

  for(int i = 0; i < s.size() ; ++i){
    
    if(s[i]=='S'){
      st.push('S');
    } else {
      if( st.empty() || st.top() == 'T' ){
	  st.push('T');
      } else if ( st.top() == 'S' ){
	st.pop();
      }
    }
    
  }
  
  cout << st.size() << endl;

  return (0);
}


Measured memory_bytes: 644
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 2200000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b) {a = b; return true;}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b) {a = b; return true;}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

void comInit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(ll 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;
    }
}


ll com(ll n, ll k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
    ll r1,c1,r2,c2; cin >> r1 >> c1 >> r2 >> c2;
    comInit();
    ll a = com(r2+c2+2,r2+1);
    ll b = com(r2+c1+1,c1);
    ll c = com(c2+r1+1,r1);
    ll d = com(r1+c1,r1);
    ll ans = a - b - c + d;
    while(ans<0) ans += mod;
    ans %= mod;
    cout << ans << endl;
}

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


int main() {
  int N, x;
  cin >> N >> x;
  int a[110];
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  sort(a, a+ N);
  int count = 0;
  for(int i = 0; i < N; ++i) {
    x -= a[i];
    if( x < 0) {
      break;
    }
    if (i == N-1 && x!= 0) {
      --count;
    }
    count++;
  }

  cout << count << endl;
}

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

int main(){
    vector<int> V(5);
    int ans = 1000;
    for(int i = 0; i < 5; ++i) cin >> V[i];
    for(int i = 0; i < 5; ++i){
        int buf = 0;
        for(int j = 0; j < 5; ++j){
            if(j != i){
                if(V[j] % 10 > 0) buf += 10*(V[j]/10+1);
                else buf += 10*(V[j]/10);
            }
            else buf += V[j];
        }
        ans = min(ans, buf);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

int MOD_BIG = 1000000007;
int MOD_BIG2 = 998244353;
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

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

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

int main() {
    
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    std::sort(A.begin(), A.end(), std::greater<ll>());
    ll ans = 0;
    int target = 1;
    int cnt = 0;
    FOR(i, 2, N) {
        ans += A[target];
        cnt++;
        if (cnt == 2) {
            cnt = 0;
            target++;
        }
    }
    ans += A[0];
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 4836
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  string s,t;
  cin>>s>>t;
  t.pop_back();
  if(s==t){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  scanf("%d", &n);

  vector<int > v;
  
  REP(i,n){
    int t;
    scanf("%d", &t);
    v.pb(t);
  }

  int ans = 0, same = 0;
  REP(i,n){
    if(v[i] == i + 1){
      same++;
    }else if(same >= 1){
      ans += same / 2 + same % 2;
      same = 0;
    }

    if(i == n - 1){
      if(same >= 1){
        ans += same / 2 + same % 2;
      }
    }
  }

  printf("%d\n", ans);

  return 0;
}



Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,s=0;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
    {
      cin>>a[i];
      
    }
    sort(a,a+n);
    for(int i=1;i<n;i++)
    {
     s+=(a[i]-a[i-1]);
    }
    cout<<s<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <map>

using ll = long long;

using namespace std;

int main() {
    int n;
    cin >> n;
    map<string, int> cnt;
    for (int i=0; i<n; i++) {
        string s; cin >> s;
        cnt[s]++;
    }
    for (auto &s:{"AC", "WA", "TLE", "RE"}) {
        cout << s << " x " << cnt[string(s)] << '\n';
    }
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1e9 + 7;
const string YES = "Yes";
const string NO = "No";

ll a[110];

int main() {
    int n;
    cin >> n;
    priority_queue<int> q;
    ll sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    } 
    ll ans = 0;

    if(sum % 10 != 0){
        cout << sum << endl;
        return 0;
    }

    rep(i, n){
        if((sum - a[i])%10==0)continue;
        chmax(ans, sum - a[i]);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.1415926535
#define MOD 1000000007
 
int main(){
  
  ll K,A,B;
  cin >> K >> A >> B;
  
  for(ll i = A;i <= B;i++){
    if(i % K == 0){
      cout << "OK" << endl;
      goto L;
    }
  }
  cout << "NG" << endl;
L:
  return 0;
}

Measured memory_bytes: 3640
n,m = map(int,input().split())

l_L,r_L = [],[]

for val in range(m):
    l,r = map(int,input().split())

    l_L.append(l)
    r_L.append(r)

r = min(r_L)
l = max(l_L)

if r-l >= 0:
    print(r-l+1)
else:
    print(0)


Measured memory_bytes: 55896
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;

template <class T> using Vec = vector<T>;

/* 定数 */
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    u32 N;
    cin >> N;
    u32 all = 0;
    for (int i = 1; i <= N; i += 2) {
        u32 sum = 0;
        for(int j = 1; j <= N; j += 2) {
            if (i % j == 0) sum++;
        }
        if (sum == 8) all++;
    }
    cout << all << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
  char s[100002];
  int len, i, j, ans01=0, ans10=0;
  cin >> s;
  len=strlen(s);
  for(i=0; i<len; i++){
    if((s[i]-'0'-i)%2==0) ans10++;
    else ans01++;
  }
  cout << min(ans10, ans01);
  return 0;
}

Measured memory_bytes: 384
// Math = ♥️

#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 ll long long
#define ld long double
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set                            \
    tree<ll, null_type, less<ll>, rb_tree_tag, \
         tree_order_statistics_node_update>

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

    ll n, k;
    cin >> n >> k;

    ll ans = 0;
    for (int i = k + 1; i <= n; i++) {
        ll p = n / i;
        ll r = (n % i);
        ans += (i - k) * p;
        ans += max(0ll, r - k + 1);
    }

    if (k == 0) {
        ans -= n;
    }

    cout << ans << "\n";
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
nodes = [[] for i in range(N)]
edges = {}
for i in range(N-1):
    a, b = MAP()
    a -= 1; b -= 1
    nodes[a].append(b)
    nodes[b].append(a)
    edges[(a, b)] = [i, -1]


stack = [(0, -1)]
mx = 0
ans = [0] * (N-1)
while stack:
    u, prev = stack.pop()
    color = 0
    # 自分の子ノードを順番に塗り進めていく
    for v in nodes[u]:
        if v == prev:
            continue
        stack.append((v, u))
        color += 1
        a, b = min(u, prev), max(u, prev)
        # 親-自分間で使用済の色だったら1つ進める
        if a != -1 and color == edges[(a, b)][1]:
            color += 1
        a, b = min(u, v), max(u, v)
        edges[(a, b)][1] = color
        i = edges[(a, b)][0]
        ans[i] = str(color)
    # 各ノードから使った色数の最大を取る
    mx = max(mx, color)

print(mx)
print('\n'.join(ans))


Measured memory_bytes: 89248
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    
    for (int i = 1; i <= 9; i++) {
      for (int j = 1; j <= 9; j++) {
        if (i * j == N) {
          System.out.println("Yes");
          return;
        }
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 22736
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

IS = lambda: int(input())
IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

L, R = IA()

def f():
    if L // 2019 != R // 2019:
        return 0
    ans = float('inf')
    la, ra = L % 2019, R % 2019
    for i in range(la, ra):
        for j in range(i+1, ra+1):
            ans = min(ans, (i * j) % 2019)
    return ans

print(f())

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

#ifdef _PRINTDEBUG
  #include "lib/printdebug.hpp"
#else
  #define printdebug(...) 1
#endif
#define MOD_1_000_000_007 (1000000007)
#define IINF (1<<28)
#define LINF (1LL<<60)
#define rep(i, n)      REP(i, 0, (n))
#define repc(i, n)     REPC(i, 0, (n))
#define REP(i, n, m)   for (int i = (int)(n); i <  (int)(m); i++)
#define REPC(i, n, m)  for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
#define yesno(cond)       YESNO((cond), "Yes", "No")
#define YESNO(cond, a, b) cout << ((cond) ? (a) : (b)) << "\n"

namespace solver {
  using namespace std;
  typedef long long ll;

  string S;

  void init() {
    cin >> S;
  }

  bool sat(string s) {
    return unique(s.begin(), s.end()) - s.begin() == 1;
  }

  void solve() {
    int ans = 1000;
    rep(ci, S.size()) {
      char c = S[ci];
      string buffer = S;
      int cur = 0;
      while(1) {
        if(sat(buffer)) break;
        cur++;
        string T = buffer;
        buffer = "";
        rep(j, T.size()-1) {
          if(T[j] == c || T[j+1] == c) {
            buffer += c;
          } else {
            buffer += T[j];
          }
        }
      }
      ans = min(ans, cur);
    }
    cout << ans << "\n";
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  solver::init();
  solver::solve();
  return 0;
}

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

#define int long long
const int MAX = 1e15;

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

    long long n;
    cin >> n; n++;

    long long speed = 1;
    long long sum = 0;
    long long tm = 0;
    while (1) {
		if (n - (sum*2 + speed) < 0) {
			break;
		} else {
			sum += speed;
			speed *= 3;
			tm++;
		}
    }
    speed /= 3;
	sum -= speed;

	n -= sum*2 + speed;

	//cout << tm << ' ' << n << '\n';
	int ite = tm - 1;
	tm = 2*tm - 2;
// 9

    while (ite--) {
        tm += n % 3;
        n /= 3;
    }
    cout << tm + n << '\n';

    return 0;
}



Measured memory_bytes: 3208
n = gets.to_i
a, b = gets.split(' ')
a = a.to_i
b = b.to_i
points = gets.split(' ').map(&:to_i)

first = 
  points.map{ |point|point if point <= a }.compact.count
second = 
  points.map{ |point|point if point >= (a + 1) && point <= b }.compact.count
third = 
  points.map{ |point|point if point >= (b + 1) }.compact.count

puts [first, second, third].min


Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(ll i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll c;
	cin >> c;
	ll ok = -1, ng = c + 1;
	while (ng - ok > 1) {
		ll med = (ok + ng) / 2;
		if ((108 * med) / 100 <= c) ok = med;
		else ng = med;
	}
	// cout << ok << " " << (108 * ok) / 100 << endl;
	// cout << ng << " " << (108 * ng) / 100 << endl;
	if ((108 * ok) / 100 == c) cout << ok << endl;
	else cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
def divisors(n):
    res = 0
    for i in range(1, n+1):
        if n % i == 0:
            res += 1
    return res


N = int(input())
ans = 0

for i in range(1, N+1, 2):
    if divisors(i) == 8:
        ans += 1
print(ans)


Measured memory_bytes: 63052
import Foundation

extension String {
    func wordsMap<T>(_ f: (Substring) -> T?) -> [T] {
        return self.split(separator: " ").compactMap(f)
    }
}

private func readWords<T>(_ f: (Substring) -> T?) -> [T] {
    return readLine()!.wordsMap(f)
}

extension Optional {
    func pleaseAC(){
        print(self!)
    }
}

readLine().map { line -> Any in 
    let nh = line.wordsMap { Int($0) }
    let n = nh[0]
    let h = nh[1]

    var maxA = 0
    let weapons = (1...n).map { _ -> Int in
        let ab = readWords { Int($0) }
        let a = ab[0]
        let b = ab[1]
        maxA = max(a, maxA)
        return b
    }

    let niceB = weapons.filter { $0 > maxA }.sorted(by: >)

    var total = 0
    var ans = 0
    for b in niceB {
        total += b
        ans += 1
        if total >= h {
            return ans
        }
    }

    let rest = h - total

    return (rest % maxA == 0 ? 0 : 1) + rest / maxA + ans

}
.pleaseAC()


Measured memory_bytes: 15976
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string s;
    int count = 0;

    cin >> s;

    for (int i = 0; i < 3; i++)
    {
        if (s[i] == '1')
            count++;
    }

    cout << count << endl;

    return 0;
}

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

typedef long long LL;
const int M=105;

struct Point
{
	int x,y;
	Point(int x=0,int y=0)
		:x(x),y(y){}
	void read()
	{
		scanf("%d%d",&x,&y);
	}
	Point operator+=(const Point &B)
	{
		x+=B.x; y+=B.y;
		return *this;
	}
	Point operator+(const Point &B) const
	{
		Point ans=*this;
		return ans+=B;
	}
	// bool operator<(const Point &B) const
	// {

	// }
	LL operator*(const Point &B) const
	{
		return (LL)x*B.x+(LL)y*B.y;
	}
	LL operator^(const Point &B) const
	{
		return (LL)x*B.y-(LL)y*B.x;
	}
	double len()
	{
		return sqrt((double)x*x+(double)y*y);
	}
	void print()
	{
		cout<<x<<" "<<y<<endl;
	}
}p[M];

int main()
{
	int n; scanf("%d",&n);
	for(int i=0;i<n;i++)
		p[i].read();
	double ans=0.0;
	for(int i=0;i<n;i++)
		for(int j=i;j<n;j++)
		{
			int u=i,v=j;
			if((p[u]^p[v])==0&&(p[u].x^p[v].x)<0) continue;
			if((p[u]^p[v])<0) swap(u,v);
			Point sum;
			for(int k=0;k<n;k++)
			{
				if(((p[u]^p[k])>0 && (p[v]^p[k])<0)
					|| ((p[u]^p[k])==0 && (p[u]*p[k])>0)
					|| ((p[v]^p[k])==0 && (p[v]*p[k])>0))
				{
					//cout<<k<<" ";
					sum+=p[k];
				}
					
			}
			// cout<<endl;
			// cout<<i<<" "<<j<<endl;
			// sum.print();
			// cout<<endl;
			ans=max(ans,sum.len());
		}
	printf("%.15f\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define vi vector<int>
#define vvi vector<vector<int>>
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
    int n, N = 2e5 + 7;
    cin >> n;
    int cnt = 0, iy = 1;
    vector<string> y(N, "");
    for (int i = 0; i < N; ++i) y[i] = to_string(i);

    for (int i = 0; i < n; ++i) {
        string x;
        cin >> x;
        if (x != y[iy])
            cnt++;
        else
            iy++;
    }
    cout << (cnt == n ? -1 : cnt) << '\n';
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

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

    return 0;
}

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

#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second

const int N = 105;

int n, a[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    int cnt = 1;
    for (int i = 2; i <= n; i++) {
        if (a[i] == a[i - 1]) cnt++;
        else {
            ans += cnt / 2;
            cnt = 1;
        }
    }
    cout << ans + cnt / 2;
    return 0;
}

Measured memory_bytes: 256