akhauriyash/Code-Regression huggingface dataset:
s = input()
i = 0
j = len(s)-1
ans = 0
while i<j:
    if s[i]==s[j]:
        i+=1
        j-=1
        continue
    if s[i]=='x':
        i += 1
        ans += 1
    elif s[j]=='x':
        j -= 1
        ans += 1
    else:
        print(-1)
        exit()
print(ans)
        

Measured memory_bytes: 3316
from collections import deque

n = int(input())
graph = [list() for _ in range(n)]

for i in range(n):
    for j, e in enumerate(input()):
        if int(e): graph[i].append(j)

def bfs(start):
    q = deque([start])
    dist = [-1] * n
    dist[start] = 0
    length = 0
    while q:
        v = q.popleft()
        length = max(length, dist[v])
        for nv in graph[v]:
            if dist[nv] == -1:
                dist[nv] = dist[v] + 1
                q.append(nv)
            elif dist[nv] == dist[v]:
                print(-1)
                exit()
    return length + 1

ans = 0
for i in range(n):
    ans = max(ans, bfs(i))

print(ans)


Measured memory_bytes: 41584
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	string S;
	cin >> S;

	string s = "";

	reverse(S.begin(), S.end());

	for (int i = 0; i < S.length(); ++i) {
		s += S[i];
		if (s == "maerd") {
			s = "";
		}
		else if(s == "remaerd") {
			s = "";
		}
		else if(s == "esare") {
			s = "";
		}
		else if(s == "resare") {
			s = "";
		}
		else if (8 < s.length()) {
			cout << "NO" << endl;
			return 0;
		}
	}

	if (s.length() != 0) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N,M;
  cin>>N>>M;
  lint S=0;
  map<lint,lint> m;
  m[0]=1;
  REP(i,N){
    int A;
    cin>>A;
    S+=A;
    S%=M;
    m[S]+=1;
  }
  lint ans=0;
  for(auto e:m){
    // cerr<<e.first<<" "<<e.second<<endl;
    ans+=(e.second*(e.second-1))/2;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(int argc, const char * argv[]) {
    int i, n, x;
    
    cin >> n;
    
    for(i=1;i<=n;i++){
        x=i;
        
        if(x%3==0){
            cout << " " << i;
        }else{
            do{
                if(x%10==3){
                    cout << " " << i;
                    break;
                }
                x/=10;
            }while(x);
        }
    }
    
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main(){
  int s,i,a,b,c;
  while(cin>>s,s){
  while(s--){
    cin>>a>>b>>c;
    if(a==100||b==100||c==100||b+c>179||a+b+c>239)cout<<'A'<<endl;
    else if(a+b+c>209||(a+b+c>149&&(a>79||c>79)))cout<<'B'<<endl;
    else cout<<'C'<<endl;
  }}
}

Measured memory_bytes: 3000
// Tenshi ni Fureta yo!

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return *(cur == ed ? ed = buffer + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur = buffer : cur)++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

// END tpl.

const int MOD = (int) 1e9 + 7;

const int MAXN = 300;

int n;

int a[MAXN * 2 + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i <= 2 * n; ++i) a[i] = read<int>();
}

inline void solve()
{
	static int ban[MAXN * 2 + 5], vis[MAXN * 2 + 5];

	int pairs = 2 * n;
	for(int i = 1; i <= n; ++i) if(a[i * 2 - 1] != -1 && a[i * 2] != -1) ban[a[i * 2 - 1]] = ban[a[i * 2]] = 1;
	for(int i = 1; i <= 2 * n; ++i) if(a[i] != -1) vis[a[i]] = 1, --pairs, pairs -= !ban[a[i]];
	pairs /= 2;

	static int f[MAXN * 2 + 5][MAXN + 5][MAXN + 5];

	f[2 * n + 1][0][0] = 1;
	for(int i = 2 * n; i >= 1; --i)
		for(int j = 0; j <= n; ++j)
			for(int k = 0; k <= n; ++k)
			{
				if(ban[i]) f[i][j][k] = f[i + 1][j][k];
				else if(!vis[i])
					f[i][j][k] =
						(
						 f[i + 1][j + 1][k] +
						 (LL) f[i + 1][j][k + 1] * (k + 1) % MOD +
						 (j > 0 ? f[i + 1][j - 1][k] : 0)
						) % MOD;
				else f[i][j][k] =
					(
					 f[i + 1][j + 1][k] +
					 (k > 0 ? f[i + 1][j][k - 1] : 0)
					) % MOD;
			}

	int ans = f[1][0][0];
	for(int i = 1; i <= pairs; ++i) ans = (LL) ans * i % MOD;
	printf("%d\n", (ans + MOD) % MOD);
}

int main()
{
#ifdef K_ON
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 219008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define toInt(x) (x - '0')
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
  int n,a,b;
  cin >> n;
  if(n%2){
    cout << "Hello World" << endl;
  }else{
    cin >> a >> b;
    cout << a+b << endl;
  }

  return 0;
}

Measured memory_bytes: 256
# python 3.4.3
import sys
input = sys.stdin.readline
import numpy as np

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
H,W = map(int,input().split())
C = [input().rstrip() for _ in range(H)]

for i in range(H):
    print(C[i])
    print(C[i])


Measured memory_bytes: 18444
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	a := make([]int, N)
	b := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&a[i])
	}
	for i := 0; i < N; i++ {
		fmt.Scan(&b[i])
	}
	x := make([]int, N)
	for i := 0; i < N; i++ {
		x[i] = i + 1
	}
	var ac, bc int
	arr := NextPermutation(x)
	for i := 0; i < len(arr); i++ {
		aeq := true
		beq := true
		for j := 0; j < N; j++ {
			if arr[i][j] != a[j] {
				aeq = false
				break
			}
		}
		if aeq {
			ac = i + 1
		}
		for j := 0; j < N; j++ {
			if arr[i][j] != b[j] {
				beq = false
				break
			}
		}
		if beq {
			bc = i + 1
		}
	}
	fmt.Println(Abs(ac - bc))
}
func Abs(a int) int {
	return int(math.Abs(float64(a)))
}

func NextPermutation(x []int) [][]int {
	var p [][]int
	z := make([]int, len(x))
	copy(z, x)
	p = append(p, z)
	for i := 1; NextPermutationSub(sort.IntSlice(x)); i++ {
		y := make([]int, len(x))
		copy(y, x)
		p = append(p, y)
	}
	return p
}

func NextPermutationSub(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}


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

void lcs( string s1, string s2, int m, int n )
{
   int L[m+1][n+1];

   for (int i=0; i<=m; i++)
   {
     for (int j=0; j<=n; j++)
     {
       if (i == 0 || j == 0)
         L[i][j] = 0;
       else if (s1[i-1] == s2[j-1])
         L[i][j] = L[i-1][j-1] + 1;
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]);
     }
   }
   
   int i = m, j = n;
   string s="";
   while (i > 0 && j > 0)
   {
      if (s1[i-1] == s2[j-1])
      {
          s+=s1[i-1];
          i--; j--;;     
      }
      else if (L[i-1][j] > L[i][j-1])
         i--;
      else
         j--;
   }
   reverse(s.begin(),s.end());
   cout<<s<<endl;
}

int main()
{
 string s1,s2;
 cin>>s1>>s2;
  lcs(s1, s2, s1.length(), s2.length());
  return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define  REP(i, n) for(int i=0; i<(n); ++i)
#define  ALL(obj) (obj).begin(), (obj).end()
#define ll long long
#define ul unsigned long

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a;
  string s;
  cin >> a;
  cin >> s;
  if(a >= 3200)
    cout << s;
  else
    cout << "red";
  cout << endl;
  return 0;
}

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

//begin( Union-Find )//

const ll MAX_N = 1000000;


//親の番号
ll par[MAX_N];
//ノードの高さ
ll rk[MAX_N];


//n要素で初期化
void init(ll n) {
  for (ll i = 0; i < n; i++) {
    par[i] = i;
    rk[i] = 0;
  }
}

//木の根を求める
ll find(ll x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}

//xとyの属する集合を併合
void unite(ll x, ll y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  
  if (rk[x] < rk[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (rk[x] == rk[y]) rk[x]++;
  }
}

//xとyが同じ集合に属するか否か
bool same(ll x, ll y) {
  return find(x) == find(y);
}

//end( Union-Find )//

int main() {
  ll N, M; cin >> N >> M;
  init(N);
  ll a[M], b[M];
  for (ll i = 0; i < M; i++) {
    cin >> a[i] >> b[i]; a[i]--; b[i]--;
  }

  //iが属する木における連結成分の個数を管理
  ll con[N];
  for (ll i = 0; i < N; i++) {
    con[i] = 1;
  }
  
  ll ans[M];
  ans[M-1] = N*(N-1)/2;
  
  for (ll i = M-1; i >= 1; i--) {
    if (!same(a[i], b[i])) {
      ans[i-1] = ans[i] - (con[find(a[i])]*con[find(b[i])]);
      ll n = con[find(a[i])] + con[find(b[i])];
      unite(a[i], b[i]);
      con[find(a[i])] = con[find(b[i])] = n;

    } else {
      ans[i-1] = ans[i];
    }
  }
  
  for (ll i = 0; i < M; i++) {
    cout << ans[i] << endl;
  }
  
}

Measured memory_bytes: 9344
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#ifdef ONLINE_JUDGE
#define debug(x)
#define debug2(x, y)
#define debug3(x, y, z)
#define dbg(v)
#else
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
#endif

// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

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

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

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

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

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);

    int64 a, b, c, d;
    cin >> a >> b >> c >> d;
    print(max({a * c, a * d, b * c, b * d}));

    return 0;
}

/*
 _
| |__   ___ _ __  _ __
| '_ \ / __| '_ \| '_ \
| |_) | (__| |_) | |_) |
|_.__(_)___| .__/| .__/
           |_|   |_|
*/


Measured memory_bytes: 3644
N,X = map(int,input().split())
m = []
for i in range(N):
    m.append(int(input()))

m = sorted(m)
ans = 0
for i in range(N):
    if X <= 0:
        print(ans)
        exit()
    X -= m[i]
    ans += 1

print(ans + X//m[0])


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;
typedef vector<map<lli,lli>> graph;

lli n,m;
vll d;
vll t;
lli i,j;

int main(){
	cin >> n;
	d = vll(n);
	for(lli i = 0;i < n;i++){
		cin >> d[i];
	}
	cin >> m;
	t = vll(m);
	for(lli i = 0;i < n;i++){
		cin >> t[i];
	}
	sort(d.begin(), d.end());
	sort(t.begin(), t.end());
	for(i = 0,j = 0;i < m && j < n;i++,j++){
		while(j < n && t[i] != d[j]) j++; 
		if(j == n){
			cout << "NO" << endl;
			return 0;
		}
	}
	if(i == m){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3456
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (s); i >= (t); --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

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

template <class T>
void _trace(const char *s, T&& x)
{
    clog << '{';
    while(*s != '0' && *s != ',') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail)
{
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

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

    int n; cin >> n;

    cout << (800 * n) - (n / 15 * 200) << endl;

    return 0;
}


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

typedef unsigned __int128 Hash;

map<char,Hash> hashing;
const Hash a=1e9+7;
const Hash b=107;

Hash hasher(char x){  
  return hashing[x];
}

int main(){
  string s[2];
  cin>>s[0]>>s[1];
  int res=0;
  hashing['a'-1]=1;
  for(int i='a';i<'z'+1;i++){
    hashing[i]=hashing[i-1]*a+b;
  }
  for(int len=1;len<=min(s[0].size(),s[1].size());len++){
    set<Hash> hs[2];
    for(int i=0;i<2;i++){
      Hash val=0;
      for(int j=0;j<len-1;j++){
	val+=hasher(s[i][j]);
      }
      for(int j=len-1;j<s[i].size();j++){
	val+=hasher(s[i][j]);
	assert(val!=0);
	hs[i].insert(val);
	val-=hasher(s[i][j-(len-1)]);
      }
    }
    
    for(auto it=hs[0].begin();it!=hs[0].end();it++){
      if(hs[1].count(*it)){
	res=max(len,res);
      }
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 3652
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sum_A = [0] * (N + 1)
sum_B = [0] * (M + 1)

for a in range(1, N + 1):
    sum_A[a] = sum_A[a - 1] + A[a - 1]
for b in range(1, M + 1):
    sum_B[b] = sum_B[b - 1] + B[b - 1]

count = 0

# print(sum_A)
# print(sum_B)
last_index = M

for a in range(len(sum_A)):
    # print("----------------------")
    # print("a", a)
    if sum_A[a] > K:
        count = max(count, a - 1)
        break
    elif sum_A[a] == K:
        count = max(count, a)
    now = sum_A[a]
    rest = K - now
    # print("last_index", last_index)
    #able = len([i for i in sum_B[:last_index + 1] if i <= rest]) - 1

    while True:
        if last_index < 0:
            able = 0
            break
        if sum_B[last_index] > rest:
            last_index -= 1
        else:
            able = last_index
            break

    # print("now", now, "rest", rest, "able", able)
    # print("今回の最大countは", "a + able = ", a + able)
    count = max(count, a + able)
    # print("これまでの最大count", count)

print(count)


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

int main(){
	int n;
	cin >> n;
	int cut = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 2 == 0) {
			for (int j = i; j <= n; j++) {
				if (j % 2 != 0) {
					cut++;
				}
			}
		} else {
			for (int j = i+1; j <= n; j++) {
				if (j % 2 == 0) {
					cut++;
				}
			}
		}
	}
	cout << cut << endl;
	return 0;
}

Measured memory_bytes: 256
module Main (main) where

import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = do
  readInts >>= putStrLn . unwords . map show . solve

type Output = [Int]

solve :: [Int] -> Output
solve [k,x] = [x-(k-1) .. x+(k-1)]

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;


int main() {
    int n; cin >> n;
    V<ll> x(n), y(n), h(n);
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> h[i];

    int s;
    for(int i = 0; i < n; i++){
        if(h[i]){
            s = i;
            break;
        }
    }

    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            bool flag = true;
            ll H = abs(x[s] - i) + abs(y[s] - j) + h[s];
            for(int k = 0; k < n; k++){
                ll tmp = max(H - abs(x[k] - i) - abs(y[k] - j), 0LL);
                if(tmp != h[k]){
                    flag = false;
                    break;
                }
            }
            if(flag){
                cout << i << " " << j << " " << H << endl;
                return 0;
            }
        }
    }
}


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

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

    int ans = 0;

    rep(i, k+1) {
        rep(j, k+1) {
            int l = s-i-j;
            if(l >= 0 && l <= k) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>

//ACL
#include <atcoder/all>
using namespace atcoder;
//ACL END

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;

using P = std::pair<int, int>;
using ll = long long;
using ld = double;

//using bint = boost::multiprecision::cpp_int;


template<typename T, typename U>
std::istream& operator>>(std::istream& in, std::pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

const int MOD = 998244353;

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int k;
    cin>>k;
    rep(i,k)cout<<"ACL";
    cout<<endl;
}


Measured memory_bytes: 3676
def Yes():
    print('Yes')
    exit()


def No():
    print('No')
    exit()


def parse(s):
    ret = [0, 0]
    for c in s:
        if c == ')':
            if ret[0]:
                ret[0] -= 1
            else:
                ret[1] -= 1
        else:
            ret[0] += 1
    return ret


N = int(input())
S = [parse(input()) for _ in range(N)]
S.sort(key=lambda a: -a[0] - a[1])
S1 = []
S2 = []
for s in S:
    if s[0] + s[1] >= 0:
        S1 += [s]
    else:
        S2 += [s]
S1.sort(key=lambda a: -a[1])
S2.sort(key=lambda a: -a[0])
cnt = 0
for s in S1:
    cnt += s[1]
    if cnt < 0:
        No()
    cnt += s[0]
for s in S2:
    cnt += s[1]
    if cnt < 0:
        No()
    cnt += s[0]
if cnt:
    No()
Yes()


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

int main(){
    int A,B,C,X;
    cin>>A>>B>>C>>X;

    int res=0;
        for(int a=0;a<=A;++a){
            for(int b=0;b<=B;++b){
                for(int c=0;c<=C;++c){
                    int total=500*a+100*b+50*c;
                    if(total==X)++res;
                }
            }
        }
    cout<<res;
}


Measured memory_bytes: 3156
import java.util.stream.*;
import java.io.*;

public class Main {

  static int n;
  static long ans;
  static int[] a;
  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);

    in = br.readLine().split(" ");
    a = Stream.of(in).mapToInt(Integer::parseInt).toArray();

    br.close();

    ans = 0L;

    int[] compToBig = new int[4 * n];

    for(int i = 0; i < n; i++){
      if(a[i] <= n) {
        compToBig[a[i] + i + 2*n]++;
      }
    }

    for(int i = 0; i < n; i++){
      if(a[i] > n) continue;
      ans += compToBig[i - a[i] + 2*n];
    }

    PrintWriter out = new PrintWriter(System.out);
    out.println(ans);
    out.flush();

  }

}

Measured memory_bytes: 64744
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N;
  cin>>N;
  vi A={105,135,165,189,195};
  if(105>N)
    cout<<0;
  else if(N>=195)
    cout<<5;
  else
    cout<<disup(A,N);
  }


Measured memory_bytes: 256
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define fast ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p;
#define vv(a) vector< vector<a> >
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
ll mod=1000000007;
#define PI 3.141592653589793238
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll a,b,h,m;
cin>>a>>b>>h>>m;
ld ang1=(h/12.0)*360.0+(0.5*m);
ld ang2=m*6.0;
ld dif=abs(ang2-ang1);


ld x=a*a+b*b-2.0*a*b*cos((dif*PI)/180.0);
cout<<fixed<<setprecision(15)<<sqrt(x)<<endl;
return 0;
}


Measured memory_bytes: 4180
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=200050;
int n;
long long a[maxn],have[maxn]={0};
long long ans=0;
int main(){
	scanf("%d",&n);
	int last=1;
	for (int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		int c=i-a[i];
		if (c<last)  {
			printf("-1");
			return 0;
		}
		have[c]=i;
		last=c;
	}
	for (int i=n;i>0;i--)
	if (have[i]) ans+=a[have[i]];
	printf("%lld\n",ans);
}

Measured memory_bytes: 3328
#include<iostream>
using namespace std;
int main()
{
	
	int n;
	int x;
	cin >> n >> x;
	//int answer = 0;
	while (n != 0 || x != 0)
	{
		int answer = 0;
		for (int i = 1; i <= n; i++)
		{
			
			for (int j = i+1; j <= n; j++)
			{
				
				for (int k = j+1; k <= n; k++)
				{
					if (i+j+k==x)
					{
						answer = answer + 1;
					}
					
				}
			}
		}
		cout << answer << endl;
		cin >> n >> x;
	}
	
	return 0;
}
//n==0&&x==0 false <=>n!=0||x!=0 true


Measured memory_bytes: 3032
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

bool check(string a,string b,int cnt,int l){
	if(cnt==l){
		return false;
	}
	if(a[cnt]>b[cnt]){
		return true;
	}
	else if(a[cnt]==b[cnt]){
		return check(a,b,cnt+1,l);
	}
	return false;
}

int main(){
	int n,l;
	cin >> n >> l;
	string s;
	VS S;
	REP(i,n){
		cin >> s;
		S.PB(s);
	}
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(check(S[i],S[j],0,l)){
				swap(S[i],S[j]);
			}
		}
	}
	for(int i=0;i<n;i++){
		cout << S[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	string a, b; cin >> a >> b;
	queue<char>A, B;
	rep(i, 0, a.size())A.push(a[i]);
	rep(i, 0, b.size())B.push(b[i]);
	while (!A.empty() || !B.empty()) {
		if (!A.empty()) {
			char ch = A.front();
			A.pop();
			cout << ch;
		}
		if (!B.empty()) {
			char ch = B.front();
			B.pop();
			cout << ch;
		}
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int a[n],t[n];
    REP(i,n){
        cin >> a[i];
        t[i] = a[i];
    }
    sort(t, t + n);
    if(t[n - 1] == t[n - 2]){
        REP(i,n){
            cout << t[n - 1] << endl;
        }
    }else{
        REP(i,n){
            if(a[i] != t[n - 1]) cout << t[n - 1] << endl;
            else cout << t[n - 2] << endl;
        }
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n,ans=0;
    cin>>n;
    for(long long i=1; i*i<n;i++){
        if((n-i)%i==0&&(n-i)/i>i ) ans+=(n-i)/i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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 N[30][100001];

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<ll> x(n);
  rep(i, n)cin >> x[i];
  ll l;
  int q;
  cin >> l >> q;
  rep(i, n){
    N[0][i] = upper_bound(all(x), x[i]+l) - x.begin() - 1;
    if(i == n - 1)N[0][i] = n;
  }
  FOR(k, 1, 20){
    rep(i, n){
      if(N[k-1][i] < n)N[k][i] = N[k-1][N[k-1][i]];
      else N[k][i] = n;
    }
  }

  rep(i_, q){
    int a, b;
    cin >> a >> b, a--, b--;
    if(a > b)swap(a, b);
    int res = 0;
    int at = a;
    while(true){
      int k = 0;
      while(N[k][at] < b){
        k++;
      }
      if(N[k][at] == b || k == 0){
        cout << res + (1 << k) << endl;
        break;
      }
      k--;
      res += 1 << k;
      at = N[k][at];
    }
  }
	return 0;
}


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

signed main(void)
{
	long long k, n;
	queue<long long> q;

	cin >> k;
	for(int i = 1; i < 10; i++) q.push(i);
	rep(i, k)
	{
		n = q.front(); q.pop();
		if (n % 10 != 0)
			q.push(n * 10 + (n % 10 - 1));
		q.push(n * 10 + n % 10);
		if (n % 10 != 9)
			q.push(n * 10 + (n % 10 + 1));
	}
	cout << n << endl;
	return 0;
}


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

using namespace std;

int main() {

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

	double r;
	const double PI = 3.141592653589793;
	cin >> r;
	cout << 2 * PI * r << '\n';

	return 0;
}

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

int main(){
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    vector<int> water;
    vector<int> sugar;
    for(int i = 0; i <= F / (100 * A); ++i){
        for(int j = 0; j <= F / (100 * B); ++j){
            if(100*A*i+100*B*j<=F) water.push_back(100*A*i+100*B*j);
        }
    }
    for(int i = 0; i <= (F / (100 + E)) * E / C; ++i){
        for(int j = 0; j <= (F / (100 + E)) * E / D; ++j){
            if(C*i+D*j<=(F / (100 + E)) * E) sugar.push_back(C*i+D*j);
        }
    }
    double conc = 0.0;
    int wt_ans = 0;
    int sg_ans = 0;
    for(int i = 0; i < water.size(); ++i){
        for(int j = 0; j < sugar.size(); ++j){
            if(water[i]+sugar[j]<=F){
                double tmp = 100.0*sugar[j]/(water[i]+sugar[j]);
                if(100.0*E/(100+E)>=tmp){
                    if(tmp >= conc){
                        conc = tmp;
                        wt_ans = water[i];
                        sg_ans = sugar[j];
                    }
                }
            }
        }
    }
    
    cout << wt_ans + sg_ans << " " << sg_ans << endl;
    return 0;
}

Measured memory_bytes: 640
import sys

input = sys.stdin.buffer.readline

from itertools import combinations_with_replacement

n, m, q = map(int, input().split())

ABCD = [list(map(int, input().split())) for _ in range(q)]

kumiawase = list(combinations_with_replacement(range(1, m + 1), n))

ans = 0
for kumi in kumiawase:
    A = [0] + list(kumi)
    temp = 0
    for abcd in ABCD:
        a, b, c, d = abcd
        if A[b] - A[a] == c:
            temp += d
    ans = max(ans, temp)

print(ans)


Measured memory_bytes: 87056
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<climits>
#define ff first
#define ss second
#include<map>
#include<unordered_map>
#define ll long long
#define ff first
#define ss second
#define fr(i,n) for(ll i=0;i<n;i++)

using namespace std;

void solve (){
    ll a, v;
  	cin>>a>>v;
  	cout<<a*v;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //ll t,tt=1;cin>>t;
   // while(t--){
	//cout<<"Case #"<<tt<<": ";	++tt;
        solve();
     //   cout<<"\n";
    //}
    return 0;

//secret access key IBtL+Zl9DVzgp7eNZWYNSBN9SSkM0PzRsoz5hIpE	c60691jTSVCKTzwnV/+Emcb4v7QZ2ZFlHobJL+Pq
//password $q}'gisyzHoK
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,i,j,k,l,m,n,ans,tmp,hoge,fuga,piyo;
ll x[10010],y[10010];
string s,str;
int main(){
  cin>>n;
  for(int i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0){
      ans+=i;
    }
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long int
#define pii <pair<ll,ll>>
using namespace std;

void solve()
{
    ll a,b,c;
    cin >> a >> b >> c;
    ll d=b+c;
    if(d<=a)
    {
        cout << "0" << endl;
    }
    else
    {
        cout << d-a << endl;
    }
}

int main()
{
     solve();
     return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<unordered_map>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 50
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S;
ll ans = 0;

int main() {
	cin >> A >> B >> C;
	ll mx = max(A, max(B, C));
	if ((3 * mx - A - B - C) % 2) {
		ans = (3 * (mx + 1) - A - B - C) / 2;
	}
	else ans = (3 * mx - A - B - C) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func rScan() []rune {
	return []rune(Scan())
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func mod(x, d int) int {
	x %= d
	if x < 0 {
		x += d
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := -int(1e+18)
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := int(1e+18)
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}
func fSum(a []float64) float64 {
	x := 0.
	for _, v := range a {
		x += v
	}
	return x
}
func bPrint(f bool, x string, y string) {
	if f {
		fmt.Println(x)
	} else {
		fmt.Println(y)
	}
}
func iSSPrint(x []int) {
	fmt.Println(strings.Trim(fmt.Sprint(x), "[]"))
}

var lp1 int = 1000000007
var lp2 int = 998244353

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, lp1)
	sc.Split(bufio.ScanWords)
	n := iScan()
	k := iScan()
	l, r := make([]int, k), make([]int, k)
	for i := 0; i < k; i++ {
		l[i], r[i] = iScan(), iScan()
	}
	p := make([]int, n)
	p[0] = 1
	for i := 1; i < n; i++ {
		for j := 0; j < k; j++ {
			if i-l[j] >= 0 {
				if i-r[j]-1 < 0 {
					p[i] += p[i-l[j]]
				} else {
					p[i] += p[i-l[j]] - p[i-r[j]-1]
				}
				p[i] %= lp2
			}
		}
		p[i] += p[i-1]
		p[i] %= lp2
	}
	ans := (p[n-1] - p[n-2]) % lp2
	ans = ans + lp2
	ans %= lp2
	fmt.Println(ans)
}


Measured memory_bytes: 3404
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  string a, b, c;
  cin >> a >> b >> c;
  char start = a[0];
  a.erase(a.begin());
  while(true) {
    if(start == 'a'){
      if(a.empty()){
        cout << "A\n";
        return 0;
      }
      start = a[0];
      a.erase(a.begin());
    }else if(start == 'b'){
      if(b.empty()){
        cout << "B\n";
        return 0;
      }
      start = b[0];
      b.erase(b.begin());
    }else{
      if(c.empty()){
        cout << "C\n";
        return 0;
      }
      start = c[0];
      c.erase(c.begin());
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) 
{
	int ramen=700;
	char topping[10]; 
	scanf("%s",topping);
	if (topping[0]=='o') ramen +=100;
	if (topping[1]=='o') ramen +=100;
	if (topping[2]=='o') ramen +=100;
	printf ("%d",ramen);
	return 0;
	
	
}

Measured memory_bytes: 128
import math
# 6,5の面を順に出し続けるのが最善
x = int(input())
tmp = math.ceil(x / 11)  # 6,5の面の順に出した回数
if 11 * tmp - x >= 5:
    # この条件を満たすと、最後のセットに5の面を出す必要がなかったことがわかる
    ans = tmp * 2 - 1
else:
    ans = tmp * 2
print(ans)

Measured memory_bytes: 3060
n = int(input())

# n % k = 1 の数
m = n - 1
i = 2
ans = 1
while i * i <= m:
    if m % i == 0:
        num = 1
        while m % i == 0:
            num += 1
            m //= i
        ans *= num
    i = i + 1
if m != 1:
    ans *= 2
ans -= 1

# n % k = 0 の場合
# nを素因数分解する
m = n
import numpy as np
i = 2
factor = []
while i * i <= n:
    if n % i == 0:
        l = []
        num = 1
        l.append(num)
        while n % i == 0:
            num *= i
            l.append(num)
            n //= i
        factor.append(np.array(l))
    i = i + 1
if n > 1:
    factor.append(np.array([1, n]))

# 直積を求めることでnの全約数を得る
divisor = factor[-1]
for i in range(len(factor) - 1):
    divisor = np.outer(divisor, factor[i])
divisor = np.outer(np.array(1), divisor)

# 判定
for i in divisor[0]:
    if i == 1:
        continue
    n = m
    while n % i == 0:
        n //= i
    if n % i == 1:
        ans += 1

print(ans)

Measured memory_bytes: 14276
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
typedef long long LL;
const int MAXN = 1e5 + 10;

LL x[MAXN], y[MAXN];
int main() {
  int n;
  scanf("%d", &n);

  for (int i = 1; i <= n; i++) {
    scanf("%lld%lld", x + i, y + i);
  }

  LL y0 = -((1ll << 60) - 1);
  LL x0 = 0;
  
  for (int i = 61; i >= 0; i--) {
    LL x1 = x0 + (1ll << i);

    int cnt = 0;
    for (int j = 1; j <= n; j++) {
      if (x[j] <= x1 && !((x1 - x[j]) & ~(y[j] - y0))) cnt ^= 1;
    }

    if (cnt) x0 = x1;
  }

  printf("%lld\n", x0 + y0);
  
}


Measured memory_bytes: 1664
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int nmax=100005;
vector<int> v[nmax];
int n,i,k,j,nr;
int main()
{
    cin>>n;
    if(n==1)
    {
        k=1;
        cout<<"Yes\n";
        cout<<2<<'\n';
        cout<<k<<' '<<k<<'\n';
        cout<<k<<' '<<k<<'\n';
        return 0;
    }
    for(i=1;i*(i-1)/2<=n;i++)
        if(i*(i-1)/2==n)
          k=i;
    if(!k)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes\n";
        cout<<k<<'\n';
        for(i=1;i<=k;i++)
            for(j=i+1;j<=k;j++)
        {
            ++nr;
            v[i].push_back(nr);
            v[j].push_back(nr);
        }
        for(i=1;i<=k;i++)
        {
            cout<<v[i].size()<<' ';
            for(int j=0;j<v[i].size();j++)
                cout<<v[i][j]<<' ';
            cout<<'\n';
        }
    }
    return 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
vector<int>prime;
void makePrime(long n){
    prime.push_back(2);
    for(long i=3;i<=n;i+=2){
        bool chk = true;
        for(int j=0;j<prime.size() && prime[j]*prime[j] <= i;j++){
            if(i % prime[j]==0){
                chk=false;
                break;
            }
        }
        if(chk)prime.push_back(i);
    }
}
int main(){
    long n;
    cin >> n;

    
    long ans = 0;
    for(long i=1;i<=n;i++){
        long tmp = n / i;
        ans += i * tmp * (tmp+1)/2;
    }
    cout << ans << endl;

    
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using pii = std::pair<int, int>; 
const int MAXN = 2500;
const int INF = (int)1e9;

std::vector<pii> edge[MAXN];  // pii = (to, cost)
std::vector<int> reverse_edge[MAXN];
int min_dis[MAXN];
bool can_reach_dest[MAXN];

void dfs_reverse_graph(int u) {
  for (const auto &v : reverse_edge[u]) {
    if (can_reach_dest[v]) continue;
    can_reach_dest[v] = true;
    dfs_reverse_graph(v);
  }
}

void shortest_path(int s, int n) {
  for (int i = 0; i < n; ++i) min_dis[i] = INF;
  min_dis[s] = 0;
  for (int num = 1; num < n; ++num) {
    for (int i = 0; i < n; ++i) {
      if (min_dis[i] == INF) continue;
      for (const auto &cur : edge[i]) {
        int to = cur.first, cost = cur.second;
        if (min_dis[to] > min_dis[i] + cost) {
          min_dis[to] = min_dis[i] + cost;
        }
      }
    }
  }
}

bool has_min_dis(int n) {
  for (int i = 0; i < n; ++i) {
    if (min_dis[i] == INF) continue;
    for (const auto &cur : edge[i]) {
      int to = cur.first, cost = cur.second;
      if (min_dis[to] == INF) continue;
      if (min_dis[to] > min_dis[i] + cost && can_reach_dest[to]) {
        // std::cout << "u = " << i << " v = " << to << std::endl;
        return false;
      }
    }
  }
  return true;
}

int solve(int n) {
  for (int i = 0; i < n; ++i) can_reach_dest[i] = false;
  can_reach_dest[n - 1] = true;
  dfs_reverse_graph(n - 1);

  shortest_path(0, n);

  // std::cout << -min_dis[n - 1] << std::endl;

  if (has_min_dis(n)) return std::max(0, -min_dis[n - 1]);
  else return -1;
}

int main() {
  int n, m, p;
  std::cin >> n >> m >> p;
  for (int i = 0, u, v, w; i < m; ++i) {
    std::cin >> u >> v >> w;
    --u;
    --v;
    w = p - w;
    edge[u].emplace_back(v, w);
    reverse_edge[v].emplace_back(u);
  }
  std::cout << solve(n) << std::endl;
  return 0;
}


Measured memory_bytes: 640
X, N = map(int, input().split())
if N == 0:
    print(X)
    exit()

if X == 1 and N == 1:
    print(0)
    exit()

P = list(map(int, input().split()))
ans = ''

for i in range(N):
    if X-i not in P:
        ans = X-i
        break
    elif X+i not in P:
        ans = X+i
        break

print(ans)


Measured memory_bytes: 9188
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>
#include <list>
#include <stack>

using namespace std;

/* constant */

const int INF = 1 << 30;
const int mod = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

/* function */

/* main */
int main() {

    vector<int> S(4);
    vector<int> T(2);
    for (int i = 0; i < S.size(); i++) {
        cin >> S[i];
    }
    for (int i = 0; i < T.size(); i++) {
        cin >> T[i];
    }

    sort(S.begin(), S.end());
    sort(T.begin(), T.end());

    int ans = accumulate(S.begin(), S.end(), 0) + accumulate(T.begin(), T.end(), 0)
                - S[0] - T[0];
    cout << ans << '\n';

}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define vel V<long long>
#define rep(i,n) for(int i=0;i<n;i++)
vel solve(V<vel>& ab, int ex) {
	if (!ex) { return { 1, 0 }; }
	V<V<vel>> qab(2);
	for (vel x : ab) {
		qab[x[1] & 1].push_back({ x[0] / 2,x[1] / 2 });
		if (x[0] & 1) { qab[(x[1] + 1) & 1].push_back({ x[0] / 2,(x[1] + 1) / 2 }); }
	}
	V<vel> c(3, vel(2));
	rep(i, 2) {
		for (vel x : qab[i]) {
			int qc = (2 * x[0] + x[1]) % 3;
			if ((qc+1)%2) { c[i][0] ^= 1; }
			if (qc) { c[i][1] ^= 1; }
		}
	}
	rep(i, 2) {
		if (c[1 - i] == c[2]) {
			vel ans = solve(qab[i], ex - 1);
			ans[0] *= 2; ans[1] *= 2; ans[1] += i;
			return ans;
		}
	}
	for(vel &v:ab) { v[0]++; }
	vel ans = solve(ab, ex); ans[0]--;
	return ans;
}
int main() {
	long long inf = 2e17;
	int n; cin >> n;
	V<vel> ab(n);
	rep(i, n) {
		long long a, b; cin >> a >> b;
		ab[i] = { a + inf,b + inf };
	}
	vel ret = solve(ab, 70);
	cout << ret[0] - inf << " " << ret[1] - inf << "\n";
}

Measured memory_bytes: 37052