akhauriyash/Code-Regression huggingface dataset:
class Dice:
    # 0: top, 1: front, 2: right, 3: left, 4: back, 5: bottom
    def __init__(self, n0, n1, n2, n3, n4, n5):
        self.faces = [n0, n1, n2, n3, n4, n5]

    def move(self, op):
        tmp = self.faces[0]
        if op == 'E':
            self.faces[0] = self.faces[3]
            self.faces[3] = self.faces[5]
            self.faces[5] = self.faces[2]
            self.faces[2] = tmp
        elif op == 'N':
            self.faces[0] = self.faces[1]
            self.faces[1] = self.faces[5]
            self.faces[5] = self.faces[4]
            self.faces[4] = tmp
        elif op == 'S':
            self.faces[0] = self.faces[4]
            self.faces[4] = self.faces[5]
            self.faces[5] = self.faces[1]
            self.faces[1] = tmp
        elif op == 'W':
            self.faces[0] = self.faces[2]
            self.faces[2] = self.faces[5]
            self.faces[5] = self.faces[3]
            self.faces[3] = tmp

    def spin_horizontally(self):
        tmp = self.faces[1]
        self.faces[1] = self.faces[2]
        self.faces[2] = self.faces[4]
        self.faces[4] = self.faces[3]
        self.faces[3] = tmp

    def top(self):
        return self.faces[0]

    def front(self):
        return self.faces[1]

    def right(self):
        return self.faces[2]

n_a = list(map(int, input().split()))
n_b = list(map(int, input().split()))
dice_a = Dice(n_a[0], n_a[1], n_a[2], n_a[3], n_a[4], n_a[5])
dice_b = Dice(n_b[0], n_b[1], n_b[2], n_b[3], n_b[4], n_b[5])

ans = 'No'
for i in range(6):

    if i % 2 == 0:
        dice_a.move('S')
    else:
        dice_a.move('E')

    if dice_a.top() == dice_b.top():
        for _ in range(4):
            dice_a.spin_horizontally()
            if dice_a.front() == dice_b.front():
                break

    if dice_a.faces == dice_b.faces:
        ans = 'Yes'
        break
print(ans)



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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    bool ok = false;
    if (abs(a-c) <= d){
        ok = true;
    } else if (abs(a-b) <= d && abs(b-c) <= d){
        ok = true;
    }
    if (ok){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
n,m = map(int,raw_input().split())
ind = [[] for i in range(n+1)]
ans = [0]*(m+1)
for i in range(m):
	a,b = map(int,raw_input().split())
	ind[a].append((b,i+1))
# print ind[:4]
for i in range(1,n+1):
	ind[i].sort()
	for j in range(len(ind[i])):
		aa = str(i)
		bb = str(j+1)
		val = "0"*(6-len(aa))+aa+"0"*(6-len(bb))+bb
		ans[ind[i][j][1]] = val
for i in range(1,m+1):
	print ans[i]




Measured memory_bytes: 55836
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

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

	vector<int> l(n);

	for (int i = 0; i < n; i++) {
		cin >> l[i];

	}

	sort(l.begin(),l.end(), greater<int>());

	int ans = 0;

	for (int i = 0; i < k; i++) {
		ans += l[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
      ll a,b,c,k;
      cin>>a>>b>>c>>k;
      ll ans = 0;
      
          ans = min(a,k);
          k-=a;
          
          if(k>0)
          {
              k -= b;
          }
          if(k>0)
          {
              ans -= k;
          }
          cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#define int long long 
#define ld long double
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define loop(i,l,r) for(int i=l;i<r;i++)
#define rloop(i,r,l) for(int i=r;i>=l;i--)
#define watch(x) cerr<<(#x)<<"= "<<(x)<<endl;
#define watcharr(a) cerr<<(#a)<<"("<<sz(a)<<")= ";rep(i,sz(a))cerr<<a[i]<<",";cerr<<'\n';
#define inf 2000000000000000000LL
#define mod 1000000007
#define mod1 998244353
#define FASTIO std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;

int n,m;
vector<int> g[100005];
int vis[100005];
int len[100005];
int ans=0;

void dfs(int x){
    vis[x]=1;
    for(auto i:g[x]){
        if(!vis[i]) 
            dfs(i);
        len[x]=max(len[x],1+len[i]);
    }
}

signed main() {
    FASTIO;
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    //     freopen("stderr.txt", "w", stderr);
    // #endif

    // int tt=1;
    // cin>>tt;
    // while(tt--){
        cin>>n>>m;
        int u,v;
        rep(i,m){
            cin>>u>>v;
            g[u].pb(v);
        }
        loop(i,1,n+1) dfs(i);
        loop(i,1,n+1) ans=max(ans,len[i]);
        cout<<ans<<endl;
        
        
    // }
    cerr<<"Time Elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<" sec";
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1.0)
#define pb push_back
#define vi vector<int>
#define mapii map<int , int>
#define mapci map<char, int>
#define mapsi map<string,int>
#define FOR(i,n) for(int i = 0;i<n;i++)
#define CP(n) cout<<"Case "<<n<<": "
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
#define MAX 1000007
#define all(x)(x.begin(),x.end())
#define debug(x,c) cout<<x<<": "<<c<<" ";
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int ns = s.size();
	int nt = t.size();
	int ans = nt;
	for(int i = 0;i<=ns - nt;i++)
	{
		int c = 0;
		for(int j = 0;j<nt;j++)
		{
			if(s[i+j]==t[j])
				c++;
		}
		ans = min(ans,nt - c);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
  ll r, s, t, u;
  in3(a, b, c);
  in3(d, e, f);
  in3(g, h, i);
  j = a - b;
  k = d - e;
  l = g - h;
  m = b - c;
  n = e - f;
  o = h - i;
  p = a - d;
  q = b - e;
  r = c - f;
  s = d - g;
  t = e - h;
  u = f - i;
  bool v = true;
  if(j != k || k != l || l != j)
    v = false;
  if(m != n || n != o || o != m)
    v = false;
  if(p != q || q != r || r != p)
    v = false;
  if(s != t || t != u || u != s)
    v = false;
  if(v)
    out("Yes");
  else
    out("No");
  memi;
}

Measured memory_bytes: 256
# coding: utf-8

import sys
import math
input = sys.stdin.readline

# N = int(input())
# L = [int(x) for x in input().split()]
N, K = map(int, input().split())
# S = input()

max_pow = math.ceil(math.log2(K) + 0.9)

one_half = [0] * (max_pow + 1)
one_half[0] = 1
for i in range(1, max_pow + 1) :
    one_half[i] = one_half[i - 1] * 0.5

ans = 0
for i in range(1, N + 1) :
    pow_num = math.ceil(math.log2(K / i))
    
    if pow_num <= 0 :
        ans += 1
    else :
        ans += one_half[pow_num]

print(ans / N)


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

struct RollingHash {
  static const ll base1 = 1007, base2 = 2009;
  static const ll mod1 = 1000000007, mod2 = 1000000009;
  vector<ll> hash1, hash2, power1, power2;

  // construct
  RollingHash(const string &S) {
    ll n = (ll)S.size();
    hash1.assign(n + 1, 0);
    hash2.assign(n + 1, 0);
    power1.assign(n + 1, 1);
    power2.assign(n + 1, 1);
    for (ll i = 0; i < n; ++i) {
      hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
      hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
      power1[i + 1] = (power1[i] * base1) % mod1;
      power2[i + 1] = (power2[i] * base2) % mod2;
    }
  }

  // get hash of s[l..r-1]
  inline P get(ll l, ll r) const {
    long long res1 = hash1[r] - hash1[l] * power1[r - l] % mod1;
    if (res1 < 0) res1 += mod1;
    long long res2 = hash2[r] - hash2[l] * power2[r - l] % mod2;
    if (res2 < 0) res2 += mod2;
    return {res1, res2};
  }

  // get lcp of s[a..] and s[b..]
  inline int getLCP(int a, int b) const {
    int len = min((int)hash1.size() - a, (int)hash1.size() - b);
    int low = 0, high = len;
    while (high - low > 1) {
      int mid = (low + high) >> 1;
      if (get(a, a + mid) != get(b, b + mid))
        high = mid;
      else
        low = mid;
    }
    return low;
  }
};

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  string s;
  cin >> n >> s;
  RollingHash rhl(s);
  ll ans = 0;
  repLRE(i, 0, n - 2) {
    repLRE(j, i + 1, n - 1) {
      ll tmp = rhl.getLCP(i, j);
      chmin(tmp, j - i);
      chmax(ans, tmp);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main implements Closeable {

  private InputReader in = new InputReader(System.in);
  private PrintWriter out = new PrintWriter(System.out);

  public void solve() {
    int n = in.ni(), m = in.ni();
    for (int i = 0; i < m; i++) {
      n -= in.ni();
    }
    out.println(Math.max(-1, n));
  }

  @Override
  public void close() throws IOException {
    in.close();
    out.close();
  }

  static class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public int ni() {
      return Integer.parseInt(next());
    }

    public long nl() {
      return Long.parseLong(next());
    }

    public void close() throws IOException {
      reader.close();
    }
  }

  public static void main(String[] args) throws IOException {
    try (Main instance = new Main()) {
      instance.solve();
    }
  }
}


Measured memory_bytes: 34208
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <queue>

using namespace std;

// Dinic
template<class T>
class MaxFlow {
private:
	struct Edge {
		int v;
		int r;
		T c;
	};

private:
	vector<vector<Edge>> g;
	vector<int> d, it;

public:
	MaxFlow(int n) : g(n), d(n), it(n) {}

	void add(int u, int v, T c) {
		int i = g[u].size();
		int j = g[v].size();
		g[u].push_back({ v, j, c });
		g[v].push_back({ u, i, 0 });
	}

	T maxFlow(int s, int t) {
		T sum = 0;
		while (bfs(s, t)) {
			T f;
			while ((f = dfs(s, t, numeric_limits<T>::max())) > 0) {
				sum += f;
			}
		}
		return sum;
	}

private:
	bool bfs(int s, int t) {
		fill(it.begin(), it.end(), 0);
		fill(d.begin(), d.end(), -1);
		d[s] = 0;
		queue<int> q;
		q.push(s);
		while (!q.empty()) {
			int v = q.front();
			q.pop();
			for (Edge e : g[v]) {
				if (e.c > 0 && d[e.v] == -1) {
					d[e.v] = d[v] + 1;
					q.push(e.v);
				}
			}
		}
		return d[t] >= 0;
	}

	T dfs(int v, int t, T f) {
		if (v == t) {
			return f;
		}
		while (it[v] < g[v].size()) {
			Edge &e = g[v][it[v]++];
			if (e.c > 0 && d[v] < d[e.v]) {
				T ff = dfs(e.v, t, min(f, e.c));
				if (ff > 0) {
					e.c -= ff;
					g[e.v][e.r].c += ff;
					return ff;
				}
			}
		}
		return 0;
	}
};

int main() {
	int h, w;
	std::cin >> h >> w;

	std::vector<std::string> g(h);
	for (int i = 0; i < h; i++) {
		std::cin >> g[i];
	}

	MaxFlow<int> mf(h * w * 2);
	int sy = 0;
	int sx = 0;
	int ty = 0;
	int tx = 0;
	const int INF = h * w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (g[i][j] == '.') {
				continue;
			}
			if (g[i][j] == 'o') {
				mf.add(i * w + j, i * w + j + h * w, 1);
			}
			if (g[i][j] == 'S') {
				sy = i;
				sx = j;
				mf.add(i * w + j, i * w + j + h * w, INF);
			}
			if (g[i][j] == 'T') {
				ty = i;
				tx = j;
				mf.add(i * w + j, i * w + j + h * w, INF);
			}
			for (int ii = 0; ii < h; ii++) {
				if (ii != i && g[ii][j] != '.') {
					mf.add(i * w + j + h * w, ii * w + j, INF);
				}
			}
			for (int jj = 0; jj < w; jj++) {
				if (jj != j && g[i][jj] != '.') {
					mf.add(i * w + j + h * w, i * w + jj, INF);
				}
			}
		}
	}

	int ans = mf.maxFlow(sy * w + sx, ty * w + tx + h * w);
	if (ans >= h * w) {
		ans = -1;
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 62464
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k, a, b;
    cin >> k >> a >> b;
    if(k <= a){
        cout << 1 << endl;
        return 0;
    }
    if(a <= b){
        cout << -1 << endl;
        return 0;
    }
    int ans = (k - b - 1) / (a - b);
    ans = ans * 2 + 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

n,k = [int(i) for i in readline().split()]
r,s,p = [int(i) for i in readline().split()]
t = input()

ans = 0

for i in range(k):
    tt = t[i::k]
    l = len(tt)
    dpr = dps = dpp = 0
    for i in tt:
        if i == "r":
            dpr,dps,dpp = max(dps,dpp),max(dpr,dpp),max(dps,dpr)+p
        if i == "s":
            dpr,dps,dpp = max(dps,dpp)+r,max(dpr,dpp),max(dps,dpr)
        if i == "p":
            dpr,dps,dpp = max(dps,dpp),max(dpr,dpp)+s,max(dps,dpr)

    ans += max(dpr,dps,dpp)


print(ans)

Measured memory_bytes: 3444
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    ll h,w;
    cin>>h>>w;
    if (h!=1&&w!=1)
        cout<<(h*w+1)/2;
    else
        cout<<1;



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
ll a[20][20];
ll d[65540],tac[65540];
int main()
{
	cin >>n;
	for (int i=0;i<n;i++)
		for (int j=0;j<n;j++)
			cin >>a[i][j];
	for (int i=1;i<(1<<n);i++)
	{
		int t=0;
		while (!(i & (1<<t))) t++;
		tac[i]=tac[i^(1<<t)];
		for (int j=t+1;j<n;j++) if (i & (1<<j)) tac[i]+=a[t][j];
	}
	for (int i=1;i<(1<<n);i++)
	{
		//cout <<i<<" ###########\n";
		for (int j=0;j<n;j++)
		{
			if (!(i & (1<<j))) continue;
			int k=i^(1<<j);
			d[i]=tac[i];
			while (1)
			{
				//cout <<k<<" "<<j<<" "<<(k^(1<<j))<<" "<<d[i]<<" ##\n";
				d[i]=max(d[i],d[i^k^(1<<j)]+tac[k^(1<<j)]);
				if (!k) break;
				k=(k-1)&(i^(1<<j));
			}
		}
	}
	cout <<d[(1<<n)-1];
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  string s,t;
  cin >> s >> t;

  REP(i,n){
    cout << s[i] << t[i];
  }
  cout << endl;
  
  //cout << fixed << setprecision(10);
  return 0;
}


Measured memory_bytes: 384
//run: g++ -std=c++14 -o run_sol.exe solution.cpp -DLOCAL_JUDGE
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define INFLL 1e17
#define PI 2*acos(0.0)
#define show(x) cout<< #x <<" is "<< x <<"\n"
using namespace std;

#define FS first
#define SC second
#define PB(t) push_back(t)
#define LEN(t) ((int)t.size())
#define ALL(t) t.begin(),t.end()
#define MP(x, y) make_pair((x), (y))
#define Fill(a,c) memset(&a, c, sizeof(a))
#define POPCOUNT __builtin_popcount

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<PII> VPII;

int main() {
    #ifdef LOCAL_JUDGE
        freopen("../input.txt", "rt", stdin);
        freopen("../output.txt", "wt", stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);


    for (int n; cin >> n; ) {
        VI dp0(3, 0), dp1(3, 0);
        VI vals(3);
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 3; j++) {
                cin >> vals[j];
            }
            
            for (int j = 0; j < 3; j++) {
                dp1[j] = max(dp0[(j + 1) % 3], dp0[(j + 2) % 3]) + vals[j];
            }
            // cout << i << "= " << dp1[0] << ", " << dp1[1] << ", " << dp1[2] << "\n";
            dp0 = dp1;
        }

        cout << max(dp1[0], max(dp1[1], dp1[2])) << "\n";
    }
    
return 0;
}

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

int N;
vector<ll> A(200010, 0);
vector<ll> v;

int main(void){
    
    scanf("%d", &N);
    for(int i = 1; i <= N; ++i) scanf("%lld", &A[i]);
    
    v = A;
    for(int i = 1; i < N; ++i) v[i + 1] += v[i]; 
    
    ll ans = LLONG_MAX;
    int Lmid = 1, Rmid = 3;
    for(int m = 2; m <= N - 2; ++m){
        while(Lmid < m - 1 && v[Lmid] <= v[m] - v[Lmid]) ++Lmid;
        while(Rmid < N - 1 && v[Rmid] - v[m] <= v[N] - v[Rmid]) ++Rmid;
        if(abs(v[Lmid] - (v[m] - v[Lmid])) > abs(v[Lmid - 1] - (v[m] - v[Lmid - 1]))) --Lmid;
        if(abs((v[Rmid] - v[m]) - (v[N] - v[Rmid])) > abs((v[Rmid - 1] - v[m]) - (v[N] - v[Rmid - 1]))) --Rmid;
        ll P = v[Lmid], Q = v[m] - v[Lmid], R = v[Rmid] - v[m], S = v[N] - v[Rmid];
        ll mx = max({P, Q, R, S}), mn = min({P, Q, R, S});
        ans = min(ans, abs(mx - mn));
    }
    printf("%lld\n", ans);
    
    return 0;
}

Measured memory_bytes: 3328
numbers = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())

print(numbers[K-1])

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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
const int mod = 1000000007;

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

    vector<ll> l(n);
    for(ll i = 0; i < n; i++) {
        cin >> l[i];
    }
    asort(l);

    ll cnt = 0;
    for(ll i = 0; i < n; i++) {
        for(ll j = i + 1; j < n; j++) {
            ll k = lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
            cnt += k - (j + 1);
        }
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <assert.h>
#include <numeric>
#include <math.h>
#include <climits>

using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    if (b == 1) return 1;
    T r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

#define MOD (1000000000+7)

int w[101];
int v[101];
ll dp[100001][101];
int main() {
    ll N, W;
    cin >> N >> W;
    int MV = 0;
    REP(i, N) {
        cin >> w[i+1] >> v[i+1];
        MV += v[i+1];
    }
    
    REP(i, MV+1) {
        REP(j, N) {
            if (i == 0) dp[i][j] = 0;
            else if (j == 0) dp[i][j] = MOD;
            
            if (i-v[j+1] >= 0) {
                dp[i][j+1] = min(dp[i-v[j+1]][j]+w[j+1], dp[i][j]);
            } else {
                dp[i][j+1] = dp[i][j];
            }
        }
//cout << i << ":" << dp[i][N] << endl;
    }
    
    ll maxv = 0;
    REP(i, MV+1) {
        if (dp[i][N] <= W) maxv = max(maxv, ll(i));
    }
    cout << maxv << endl;
}


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

int main() {
 	int  a,b;
  	int ans;
  cin >> a >>b ;

  if(a%2 ==1){
     if((25*a)/2 + 1>=10*(b+1)||12.5*(a+1)<=10*b){
 		cout << -1 << endl;
 		}
    else{
      ans =max((25*a/2)+1,10*b);
    cout << ans << endl;
        }
  }
  else if(a%2 ==0){
     if(12.5*a>= 10*(b+1)|| 25*(a+1)/2+1<=10*b){
  cout << -1 << endl;
 }
    else {
  ans= max(25*a/2,10*b);
    cout << ans << endl;
    }
  }
 
}
  

Measured memory_bytes: 256
// Problem : B - Theater
// Contest : AtCoder - AtCoder Beginner Contest 073
// URL : https://atcoder.jp/contests/abc073/tasks/abc073_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int sum=0;int n;cin>>n;vp v(n);cin>>v;
for(auto p:v)
sum+=p.se-p.f+1;
cout<<sum;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n,m;
	cin>>n>>m;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	vector<bool> v(n,true);
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		if(a[x-1]>a[y-1])
			v[y-1]=0;
		else if(a[x-1]<a[y-1])
			v[x-1]=0;
		else 
		{
			v[x-1]=0;
			v[y-1]=0;
		}
	}
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(v[i]==1)
			cnt++;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 4000
N=int(input())
h=list(map(int, input().split()))

index=N-1
output='Yes'
while index>0:
  if h[index-1]-h[index]>1:
    output='No'
    break
  elif h[index-1]-h[index]==1:
    h[index-1]-=1
  else:
    pass
  index-=1
  
print(output)

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  ll n;cin>>n;
  ll i;
  vector<ll> ls(1,n);
  ls.emplace_back(n-1);
  for(i=2;i*i<=n;i++)
  {
    if(n%i==0)
    {
      ls.emplace_back(i);
      ls.emplace_back(n/i);
    }
  }
  for(i=2;i*i<=n-1;i++)
  {
    if((n-1)%i==0)
    {
      ls.emplace_back(i);
      ls.emplace_back((n-1)/i);
    }
  }
  sort(all(ls));
  ll ans=0;
  rep(i,ls.size())
  {
    if(ls[i]<2||ls[i]>n)continue;
    if(i>0&&ls[i]==ls[i-1])continue;
    ll left=n;
    while(left%ls[i]==0)left/=ls[i];
    if(left%ls[i]==1)ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3648
import sys
input=sys.stdin.readline
def chmax(a,b):
    if a>=b:
        return a
    return b
def chmin(a,b):
    if a<=b:
        return a
    return b
def main():
    N=int(input())
    a=list(map(int,input().split()))
    dp=[[0]*(N+2) for _ in range(N+2)]
    for len in range(1,N+1):
        for i in range(N+1-len):
            j=i+len
            if (N-len)%2==0:
                dp[i][j]=chmax(dp[i+1][j]+a[i],dp[i][j-1]+a[j-1])
            else:
                dp[i][j]=chmin(dp[i+1][j]-a[i],dp[i][j-1]-a[j-1])
    print(dp[0][N])
main()

Measured memory_bytes: 112652
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <math.h>

#define SWAP(a, b) a = a ^ b; b = a ^ b; a = a ^ b

void swap(int * a, int * b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}

void print_int(int n)
{
    printf("%d\n",n);
    
}

void sort(int a[], int n)
{
    int h, i, j;

    for(h = 1; h < n / 9; h = h * 3 + 1)
        continue;

    for(; h > 0; h /= 3)
    {
        for(i = h; i < n; i++)
        {
            j = i;
            while(j >= h && a[j] < a[j-h])
            {
                swap(&a[j], &a[j-h]);
                j -= h;
            }
        }
    }
}

void print_list(int a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        printf("%d ", a[i]);
    }
}

void intcpy(int a[], const int b[], int count)
{
    for(int i = 0; i < count; i++)
    {
        a[i] = b[i];
    }
}

int list_sum(int a[], int n)
{
    int sum = 0;

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

    return sum;
}


void permutate(int s[], int count, int n)
{
    if(n == count)
        return;

    for(int i = n; i < count; i++)
    {
        swap(&s[i], &s[n]);

        if(i != n)
        {
            //intcpy(result[j++], s, count);
        }
        
        permutate(s, count, n+1);
        swap(&s[i], &s[n]);
    }
}



int main(void)
{
    int a, b, t, result = 0;
    scanf("%d %d %d", &a, &b, &t);
    for (int i = a; i <= t; i += a)
    {
        result += b;
    }
    print_int(result);
    
    
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 3010;

int n;
string s;
int dp[2][N];

inline int add(int a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
  return a;
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> s;
  for (int l = 0; l < n; l++) {
    dp[1][l] = l+1;
  }
  for (int i = 1; i < n; i++) {
    for (int l = 0; l < n-i; l++) {
      if (s[i-1] == '<') {
        dp[0][l] = dp[1][l];
      } else {
        dp[0][l] = add(dp[1][n-i], MOD - dp[1][l]);
      }
      //cerr << i << " " << l << " -> " << dp[i][l] << nl;
    }
    for (int j = 1; j < n-i; j++) {
      dp[0][j] = add(dp[0][j], dp[0][j-1]);
    }
    swap(dp[0], dp[1]);
  }
  cout << dp[1][0] << nl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
book={"AC":0,"WA":0,"TLE":0,"RE":0}
for i in range(n):
    s=input()
    book[s]+=1
print("AC x "+ str(book["AC"]))
print("WA x "+ str(book["WA"]))
print("TLE x "+ str(book["TLE"]))
print("RE x "+ str(book["RE"]))

Measured memory_bytes: 9200
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cassert>
#include<queue>
#include<cstdio>
#include<ctime>
#include<climits>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

struct P
{
  vector<int> A;
  int cost;
  P(vector<int> A2=vector<int>(),int cost=inf):cost(cost)
  {
    A = A2;
  }

  bool operator < (const P& a)const
  {
    return cost > a.cost;
  }

};

int N;
map<vector<int>,int> mincost;
map<vector<int>,int> rmincost;
vector<int> initial;
bool found;

void computeR(int step)
{
  priority_queue<P> Q;
  {
    initial.resize(N);
    rep(i,N)initial[i] = i+1;
    Q.push(P(initial,0));
    rmincost[initial] = 0;
  }

  //clock_t st,ed;
  //st = clock();
  while(!Q.empty())
    {
      P p = Q.top(); Q.pop();
      if(p.cost >= step)continue;

      //ed = clock();
      //if((double)(ed-st)/(double)CLOCKS_PER_SEC >= 1.0)return;      

      rep(s,N)
	{
	  REP(t,s+2,N+1)
	    {
	      vector<int> next = p.A;
	      reverse(next.begin()+s,next.begin()+t);
	      if(rmincost.find(next) == rmincost.end())
		{
		  rmincost[next] = p.cost + 1;
		  Q.push(P(next,p.cost+1));
		}
	    }
	}

    }
}

void compute(vector<int> &vec)
{
  mincost[vec] = 0;
  priority_queue<P> Q;
  Q.push(P(vec,0));

  int ans = inf;
  found = false;
  while(!Q.empty())
    {
      P p = Q.top(); Q.pop();

      //if(p.cost >= ans)continue;


      if(rmincost.find(p.A) != rmincost.end())
	{
	  found = true;
	  cout << p.cost + rmincost[p.A] << endl;
	  return;
	  //ans = min(ans,p.cost + rmincost[p.A]);
	  continue;
	}

      if(p.cost >= 4)continue;

      rep(s,N)
	{
	  REP(t,s+2,N+1)
	    {
	      vector<int> next = p.A;
	      reverse(next.begin()+s,next.begin()+t);
	      if(mincost.find(next) == mincost.end())
		{
		  mincost[next] = p.cost + 1;
		  Q.push(P(next,p.cost+1));
		}
	    }
	}
    }
  found = true;
  cout << N-1 << endl;
}

int main()
{

  int a = scanf("%d",&N);
  
  computeR(4);
  //cout << "---------" << endl;
  vector<int> vec(N);
  rep(i,N)a = scanf("%d",&vec[i]);

  compute(vec);


  return 0;
}

Measured memory_bytes: 83280
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<long long, null_type,less<long long>, rb_tree_tag,tree_order_statistics_node_update>
//s.find_by_order(index) returns iterator to the index-th element
//in O(logn) time.



typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vii;
typedef vector<string> vss;
typedef vector<pair<ll, ll> > vpll;
typedef unordered_map<ll ,ll> mpll;
typedef unordered_map<int ,int> mpii;
typedef unordered_map<char ,ll> mpcl;
typedef pair<ll , ll> pll;
typedef complex<double> cd;
typedef vector< complex<double> > vcd;


#define fore(i,n) for(i=0;i<n;i++)
#define forz(i,s,f) for(i=s;i<f;i++)
#define forer(i,n) for(i=n-1;i>=0;i--)
#define forzr(i,s,f) for(i=s;i>=f;i--)
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ff first
#define ss second
#define pvec(i,vec) fore(i,vec.size())cout<<vec[i]<<" ";cout<<"\n";

const ll mod=1e9+7;
const ll modulo=998244353;
const double pi = 3.14159265358979323846;


ll power(ll x,ll y,ll m)//gives (x^y)%m
{
    ll ans=1;
    while (y>0)
    {
        if(y & 1)
        {
            ans=(ans*x)%m;
        }
        y=y/2;
        x=(x*x)%m;
    }
    return ans;
}

bool sortbysec(pll &a,pll &b)
{
    return(a.ss<b.ss);
}

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

ll lcm(ll a,ll b)
{
	ll ans=(a*b)/gcd(a,b);
	return ans;
}

long double logn(long double a,long double n)
{
	return(log(n)/log(a));
}

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
    
	ll te=1,test,i,j,n,m,flag,k,p,temp,x,y,z;
	//cin>>te;
	for(test=1;test<=te;test++)
	{
		cin>>n;
		mpll mp;
		forz(x,1,101)
		{
			forz(y,1,101)
			{
				forz(z,1,101)
				{
					temp=(x*x+y*y+z*z+x*y+y*z+x*z);
					mp[temp]++;
				}
			}
		}

		forz(i,1,n+1)
		{
			cout<<mp[i]<<"\n";
		}
		/*vll a(n);
		fore(i,n)
		{
			cin>>a[i];
		}*/
		
		//cout<<"hello\n";
		//cout<<"Case #"<<test<<": ";
	}

	return 0;
}

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

int main() {
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }

    ll lo = 0, hi = 1e12;
    ll ret = 0, cnt = 0;
    sort(A.begin(), A.end());
    
    vector<ll> AS(N + 1);
    for (int i = 0; i < N; ++i) {
        AS[i + 1] = AS[i] + A[i];
    }

    while (hi - lo > 1) {
        ll c = (lo + hi) / 2;
        ret = 0;
        cnt = 0;
        for (auto a : A) {
            auto itr = lower_bound(A.begin(), A.end(), c - a);
            int i = itr - A.begin();
            cnt += A.end() - itr;
            ret += AS[N] - AS[i] + (A.end() - itr) * a;
        }
        (cnt >= M ? lo : hi) = c;
    }
    cout << ret - (cnt - M) * lo << endl;
    return 0;
}

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

string S, T;
ll Q, A, B, C, D;

void init(const string &S, string &s) {
  s = "X";
  REP(i, 0, S.length()) {
    if(s[i] == 'A' && S[i] == 'A') s += "B";
    if(s[i] == 'B' && S[i] == 'B') s += "A";
    if(s[i] == 'A' && S[i] == 'B') s += "X";
    if(s[i] == 'B' && S[i] == 'A') s += "X";
    if(s[i] == 'X' && S[i] == 'A') s += "A";
    if(s[i] == 'X' && S[i] == 'B') s += "B";
  }
}

char which(const string &s, ll l, ll r) {
  if(s[l] == 'A' && s[r] == 'A') return 'X';
  if(s[l] == 'B' && s[r] == 'B') return 'X';
  if(s[l] == 'A' && s[r] == 'B') return 'A';
  if(s[l] == 'B' && s[r] == 'A') return 'B';
  if(s[l] == 'X' && s[r] == 'A') return 'A';
  if(s[l] == 'X' && s[r] == 'B') return 'B';
  if(s[l] == 'A' && s[r] == 'X') return 'B';
  if(s[l] == 'B' && s[r] == 'X') return 'A';
  if(s[l] == 'X' && s[r] == 'X') return 'X';
}

int main(void) {
  cin >> S >> T;

  string s, t;
  init(S, s);
  init(T, t);

  cin >> Q;
  REP(i, 0, Q) {
    cin >> A >> B >> C >> D;
    if(which(s, A - 1, B) == which(t, C - 1, D)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}


Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<tuple>
#include<utility>
#include<stack>
using namespace std;

using ll=long long int;


int main() {

	int n, a, b;
	cin >> n >> a >> b;

	cout << min(n * a, b) << endl;

	return 0;
}





Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    x,y,z,k=map(int,readline().split())
    a=list(map(int,readline().split()))
    b=list(map(int,readline().split()))
    c=list(map(int,readline().split()))

    d=list()
    for i in range(x):
        for j in range(y):
            d.append(a[i]+b[j])

    d.sort(reverse=True)
    if x*y>=k:
        d=d[:k]

    e=list()
    for i in range(len(d)):
        for j in range(z):
            e.append(d[i]+c[j])

    e.sort(reverse=True)
    for i in range(k):
        print(e[i])

if __name__=="__main__":
    main()

Measured memory_bytes: 136812
#include <iostream>
#include <cstdio>
#include <stack>
#include <vector>
using namespace std;

#define BUF_SIZE 20001

int main(void){
    char buf[BUF_SIZE];
    fgets(buf, BUF_SIZE, stdin);
    int A = 0;
    stack<int> s1;
    stack<pair<int, int> > s2;
    for(int i = 0; buf[i] != '\0'; ++i){
        if(buf[i] == '\\')
            s1.push(i);
        else if(buf[i] == '/' && s1.size() > 0){
            int j = s1.top();
            s1.pop();
            int a = i - j;
            A += a;
            while(s2.size() > 0 && s2.top().first > j){
                a += s2.top().second;
                s2.pop();
            }
            s2.push(make_pair(j, a));
        }
    }
    int k = s2.size();
    printf("%d\n%d", A, k);
    vector<int> L(k, 0);
    for(int i = k - 1; i >= 0; --i){
        L[i] = s2.top().second;
        s2.pop();
    }
    for(int i = 0; i < k; ++i){
        if(i == 0)
            printf(" ");
        printf("%d", L[i]);
        if(i != k - 1)
            printf(" ");
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int L,R,D;
    cin >> L >> R >> D;
    int ans = 0;
    for(int i=L;i<=R;i++) ans += i%D==0;
    cout << ans << "\n";
}

Measured memory_bytes: 3636
n,m=map(int,input().split())
h=list(map(int,input().split()))
road = [[]for _ in range(n+3)]
for i in range(m):
    a,b=map(int,input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)

e = [True]*n
ten = []
for i,a in enumerate(h):
    ten.append((a,i))

for a,i in sorted(ten,reverse=True):
    if e[i] == True:
        for r in road[i]:
            if a > h[r]:
                e[r] = False
            else:
                e[i] = False
            
print(e.count(True))

Measured memory_bytes: 41752
using System;
class Program{
 static void Main(string[] args){
   int n = int.Parse(Console.ReadLine());
   string str = Console.ReadLine();
   
   string ans = "";
   if(n%2 == 1){
    ans = "No";
   }else if(str.Substring(0,n/2) == str.Substring(n/2,n/2)){
    ans = "Yes"; 
   }else{
    ans = "No"; 
   }
   
   Console.WriteLine(ans);
 }
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll positive = 0, negative = 0;
    ll count = 0;
    ll N;
    vector<ll> A, B, source;
    cin >> N;
    A.resize(N);
    B.resize(N);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N) {
        ll diff = A[i] - B[i];
        if(diff < 0) {
            negative -= diff;
            count++;
        } else {
            positive += diff;
            source.push_back(diff);
        }
    }
    if(positive >= negative) {
        sort(source.begin(), source.end(), greater<>());
        iter(i, source) {
            if(negative <= 0) break;
            negative -= i;
            count++;
        }
        cout << count << endl;
    } else {
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 2936
n = int(input())
 
from collections import Counter
 
f = Counter()

factors = []
for i in range(2, min(int(n ** 0.5 + 1), n + 1)):
  if n % i == 0:
      factors.append(i)
      factors.append(n // i)

factors.sort()

for factor in factors:
    while n % factor == 0:
        n //= factor
        f[factor] += 1

 
    
def bsearch(test, lo, hi):
  while lo != hi:
    mid = (lo + hi + 1) // 2
    if test(mid):
      lo = mid
    else:
      hi = mid - 1
  return lo
 
ans = 0
for p, q in f.items():
  ans += bsearch(lambda w: w * (w + 1) // 2 <= q, 0, 10 ** 12)
 
if ans == 0 and n > 1:
    print(1)
else:
    print(ans)


Measured memory_bytes: 9628
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>

#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using pp = pair<int, int>;
constexpr long long INF = 1e10;
constexpr double EPS = 1e-10;
constexpr long long MOD = 998244353;

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

    int H, W;
    int white = 0;
    cin >> H >> W;
    vector<vector<char>> field(100, vector<char>(100, '#'));
    vector<vector<int>> score(100, vector<int>(100, -1));
    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            cin >> field[i][j];
            if(field[i][j] == '.') white++;
        }
    }

    queue<pp> que;
    que.push(make_pair(1, 1));
    score[1][1] = 1;
    int dx[] = {1, 0, -1, 0};
    int dy[] = {0, 1, 0, -1};
    while(!que.empty()) {
        pp p = que.front();
        que.pop();
        if(p.first == H && p.second == W) {
            break;
        }
        for(int i = 0; i < 4; i++) {
            int nx = p.second + dx[i];
            int ny = p.first + dy[i];
            if(field[ny][nx] == '.' && score[ny][nx] == -1) {
                score[ny][nx] = score[p.first][p.second] + 1;
                que.push(make_pair(ny, nx));
            }
        }
    }

    if(score[H][W] == -1) cout << -1 << endl;
    else cout << white - score[H][W] << endl;
}

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

int main()
{
    long long a, b, c, d = 0;
    scanf("%lld %lld %lld",&a,&b,&c);
    if(b>=a)
    {
        d = 1;
    }
    else if(b<=c)
    {
        d = -1;
    }
    else
    {
        d = (long long)(a-b)/(b-c);
        if((a-b)%(b-c)!=0)
        d++;
        d = 2*d+1;
    }
    printf("%lld",d);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

#define MAX 10

int main(void)
{
	int i, j, tmp;
	int x[MAX];
	
	for(i = 1;i <= 10; i++){
		scanf("%d", &x[i-1]);
	}
	for(i = 0; i < 9; i++){
		for(j = 0; j < 9 - i; j++){
			if(x[j] < x[j + 1]){
				tmp = x[j];
				x[j] = x[j + 1];
				x[j + 1] = tmp;
			}
		}
	}
	for(i = 0;i < 3; i++){
		printf("%d\n", x[i]);
	}
	return 0;
}

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

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

Measured memory_bytes: 4776
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    map<int,int>mp;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
        mp[a[i]-1]++;
        mp[a[i]+1]++;
    }
    int ans=0;
    for(auto& p:mp){
        int x=p.second;
        ans=max(ans,x);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5120
N, Q = map(int, input().split())
S = input()

import re

s = [i.span()[0] for i in list(re.finditer("AC", S))]
#print(s)

count = [0] * (N+1)
c = 0
for i in range(N):
    try:
        if s[0]+1 == i:
            s.pop(0)
            c += 1
    except:
        pass
            
    count[i] = c
    
#print(count)

ans = []
for i in range(Q):
    l, r = map(int, input().split())
    #print(S[l-1:r])
    #print(count[r-1], count[l-1])
    ans.append(count[r-1] - count[l-1])

print(" ".join(map(str, ans)))

Measured memory_bytes: 16680