akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main()
{
  int a[110000],b[110000];
  memset(b,0,sizeof(b));
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++)
  {
      scanf("%d",&a[i]);
  }
  int p=1;
  for(int i=0;;i++)
  {
      if(p==2)
      {
          printf("%d\n",i);
          break;
      }
      else if(b[p]==1)
      {
          printf("-1\n");
          break;
      }
      else
      {
          b[p]=1;
          p=a[p];
      }
  }
    return 0;
}


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

#define Flash ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define F first
#define S second
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define ll long long
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 1e5 + 1;
const long long MNN = 1 * 1e4 + 1;
const long long MOD = 1e8;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong n, a, b;

int main(){
    cin >> n >> a >> b;
    if(n == 1 && a != b || a > b){
        cout << 0;
        return 0;
    }
    cout << (n - 2) * b - (n - 2) * a + 1;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
S = input().strip()
T = input().strip()
score_list = []
for i in range(len(S) - len(T) + 1):
  s = S[i:i+len(T)]
  score = 0
  for i in range(len(s)):
    if s[i] != T[i]:
      score += 1
  score_list.append(score)
print(min(score_list))

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

int main(){
	map<int,int>m;
	vector<int>v;
	int a,b;
	while(scanf("%d,%d",&a,&b)){
		if(a==0&&b==0)break;
		m.insert(make_pair(a,b));
		
		int flg=1;
		for(int i=0;i<v.size();i++){
			if(v[i]==b){
				flg=0;
				break;
				}
			}
			
		if(flg==1)v.push_back(b);	
		}
		sort(v.begin(),v.end());
		reverse(v.begin(),v.end());
		
		int c;
		while(cin>>c){
			int d=m[c];
			
			for(int i=0;i<v.size();i++){
				if(v[i]==d){cout<<i+1<<endl;}
				}
			}
			return 0;
	}

Measured memory_bytes: 3168
//C - Tsundoku
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define N 998244353

int gcd(int m,int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  long long int n,m,k,i,j,inin,num,num2=0,ans,aa,bb,a[200010]={},b[200010]={};
  scanf("%lld %lld %lld", &n, &m, &k);
  for(i = 1; i <= n; i++) {
    scanf("%lld", &aa);
    a[i]=a[i-1]+aa;
  }
  for(j = 1; j <= m; j++) {
    scanf("%lld", &bb);
    b[j]=b[j-1]+bb;
  }

  ans=0;
  inin=0;
  for(i = 0; i <= n; i++) {
    for(j = m-num2; j >= 0; j--) {
      if(a[i]+b[j]<=k){
        ans=max(ans,i+j);
        break;
      }
      num2++;
    }
  }

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

  return 0;
}

Measured memory_bytes: 4820
// ARC093D.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 17, MAX_M = 1 << MAX_N, mod = 1e9 + 7;

int n, m, ai[MAX_N], fac[MAX_M], fac_inv[MAX_M], dp[MAX_M];

int fpow(int bas, int tim)
{
    int ret = 1;
    while (tim)
    {
        if (tim & 1)
            ret = 1LL * ret * bas % mod;
        bas = 1LL * bas * bas % mod;
        tim >>= 1;
    }
    return ret;
}

int binomial(int n_, int k_) { return (n_ < k_) ? 0 : 1LL * fac[n_] * fac_inv[k_] % mod * fac_inv[n_ - k_] % mod; }

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++)
        scanf("%d", &ai[i]);
    for (int i = fac[0] = fac_inv[0] = 1; i < MAX_M; i++)
        fac[i] = 1LL * fac[i - 1] * i % mod;
    fac_inv[MAX_M - 1] = fpow(fac[MAX_M - 1], mod - 2);
    for (int i = MAX_M - 2; i >= 0; i--)
        fac_inv[i] = 1LL * fac_inv[i + 1] * (i + 1) % mod;
    sort(ai + 1, ai + 1 + m), dp[0] = 1, reverse(ai + 1, ai + 1 + m);
    for (int i = 1; i <= m; i++)
        for (int stat = (1 << n) - 1; stat >= 0; stat--)
            for (int j = 0; j < n; j++)
                if (stat & (1 << j))
                    dp[stat] = (0LL + dp[stat] + 1LL * dp[stat ^ (1 << j)] * binomial((1 << n) - ai[i] - (stat - (1 << j)), (1 << j) - 1) % mod * fac[1 << j] % mod) % mod;
    int ans = 0;
    for (int stat = 0; stat < (1 << n); stat++)
        if (__builtin_popcount(stat) & 1)
            ans = (0LL + ans + mod - 1LL * dp[stat] * fac[(1 << n) - stat - 1] % mod) % mod;
        else
            ans = (0LL + ans + 1LL * dp[stat] * fac[(1 << n) - stat - 1] % mod) % mod;
    printf("%lld\n", 1LL * ans * (1 << n) % mod);
    return 0;
}

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

int main()
{
	int a, b;
	string sa, sb;

	cin >> a >> b;

	for (int i = 0; i < b; i++) {
		sa += (char)(a + '0');
	}
	for (int i = 0; i < a; i++) {
		sb += (char)(b + '0');
	}

	if (sa <= sb) cout << sa << endl;
	else  cout << sb << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cctype>

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

    bool cond1 = S[0] == 'A';
    bool cond2 = std::count(S.begin() + 2, S.end() - 1, 'C') == 1;
    bool cond3 = std::count_if(S.begin(), S.end(), isupper) == 2;
    std::cout << (cond1 && cond2 && cond3 ? "AC" : "WA") << std::endl;
}


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

int main() {
	int N, K; cin >> N >> K;
	vector<int> a(N);
	for(int i=0; i<N; ++i) cin >> a[i];
	vector<vector<vector<long>>> dp(N+1, vector<vector<long>>(256, vector<long>(N+1, 0)));
	long mod=1000000007;
	dp[0][0][0]=1;
	for(int i=0; i<N; ++i){
	    for(int j=0; j<256; ++j){
	        for(int k=0; k<=i; ++k){
	            dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k])%mod;
	            dp[i+1][j^a[i]][k+1]=(dp[i+1][j^a[i]][k+1]+dp[i][j][k])%mod;
	        }
	    }
	}
	vector<long> frc(N+1, 1);
	for(int i=1; i<=N; ++i) frc[i]=(frc[i-1]*i)%mod;
	long ans=0;
	for(int i=1; i<=N; ++i) ans=(ans+dp[N][K][i]*frc[i])%mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 21632
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  ll k, s;
  cin >> k >> s;
  ll ans = 0;
  for (int x = 0; x <= k; x++) {
    for (int y = 0; y <= k; y++) {
      int z = s - x - y;
      if (0 <= z && z <= k) ans++;
    }
  }

  cout << ans << 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++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    int N, a;
    cin >> N;
    map<int, int> mp;
    rep(i, N){
        cin >> a;
        if(mp.count(a)) mp[a]++;
        else mp[a] = 1;
    }
    bool able = false;
    map<int, int>::iterator ite;;
    if(mp.size() == 1){
        ite = mp.begin();
        int n = ite->first;
        if(n == N-1 || N >= 2*n) able = true;
    }
    elif(mp.size() == 2){
        ite = mp.begin();
        int a = ite->first;
        ite++;
        int b = ite->first;
        if(a == b+1 || b == a+1){
            int n = max(a, b);
            int m = mp[n-1];
            if(m < n && (n-m)*2 <= N-m) able = true;
        }
    }
    if(able) cout << "Yes" << endl;
    else cout << "No" << endl; 
}

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


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 (ll)1 << 60
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


ll n, m, p;
vector<ll> list[210000];
int main() {
	cin >> n >> m;
	
	REP(i, n + m - 1) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		list[a].push_back(b);
	}
	//トポロジカルソート
	vector<ll> in(n), ans(n); // 答え
	queue<ll> que;
	//入次数
	REP(i, n) { //隣接リストの長さ
		REP(j, list[i].size()) { //隣接リストの変数名
			in[list[i][j]]++;
		}
	}
	REP(i, n) if (in[i] == 0)que.push(i);
	p = que.front();
	while (!que.empty()) {
		ll now = que.front();
		que.pop();
		REP(i, list[now].size()) {
			in[list[now][i]]--;
			if (in[list[now][i]] == 0) {
				ans[list[now][i]] = now;
				que.push(list[now][i]);
			}
		}
	}
	REP(i, ans.size()) {
		if (i == p)cout << 0 << endl;
		else cout << ans[i] + 1 << endl;
	}
}

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

int main() {
    string s;
    int q, t_cnt = 0;
    cin >> s >> q;
    deque<char> str;
    for (size_t i = 0; i < s.size(); i++) {
        str.push_back(s.at(i));
    }
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            t_cnt++;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (t_cnt % 2 == 0) {
                f == 1 ? str.push_front(c) : str.push_back(c);
            } else {
                f == 2 ? str.push_front(c) : str.push_back(c);
            }
        }
    }
    if (t_cnt % 2 == 1) reverse(str.begin(), str.end());
    for (auto &x : str) cout << x;
    cout << endl;
}


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

#define is_uruu leapyear
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(a);i>(b);--i)
#define REP(i,a) for(int i=0;i<(a);++i)


 
int main()
{
	int n, a, to, A[200005];
	cin >> n;
	
	FOR(i, 0, n){
		scanf("%d", &a);
		if(i%2 == n%2){
			to = n/2+(i+1)/2;
		} 
		else {
			to = n/2-(i+1)/2;
		}
		A[to] = a;
	}
	
	FOR(i, 0, n){
		printf("%d%c", A[i], i==n-1?'\n':' ');
	}
	
	return 0;
}

Measured memory_bytes: 2944
import sys

def main():
	for line in sys.stdin:
		data = map(int, line.strip().split(','))
		print analyze(data)

def analyze(data):
	lengths = data[:10]

	D = sum(lengths)

	v1 = data[10]
	v2 = data[11]

	mp = 1.0 * v1 / (v1 + v2) * D

	s = 0
	for i in xrange(10):
		s += lengths[i]
		if mp <= s:
			return i + 1

	return -1


main()

Measured memory_bytes: 4240
import java.util.*;

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

    int N = in.nextInt();
    int M = in.nextInt();
    int X = in.nextInt();
    int ans = -1;

    int[] prices = new int[N];
    int[][] books = new int[N][M];

    for (int i = 0; i < N; i++) {
      prices[i] = in.nextInt();
      for (int j = 0; j < M; j++) {
        books[i][j] = in.nextInt();
      }
    }

    for (int i = 0; i < (1 << N); i++) {
      int p = 0;
      int[] understandings = new int[M];

      for (int j = 0; j < N; j++) {
        if ((i & (1 << j)) > 0) {
          p += prices[j];
          for (int k = 0; k < M; k++) {
            understandings[k] += books[j][k];
          }
        }
      }

      boolean valid = true;
      for (int j = 0; j < M; j++) {
        if (understandings[j] < X) {
          valid = false;
          break;
        }
      }

      if (valid) {
        if (ans == -1) {
          ans = p;
        } else {
          ans = Math.min(ans, p);
        }
      }
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 37452
a, b =map(int, input().split())
def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True
cnt = 0
for i in range(a, b+1):
    if is_kaibun(str(i)):
        cnt += 1
print(cnt)

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

int main() {
	int a,b,c;
	cin >> a;
	if (a < 1200) {
		cout << "ABC" << endl;
	} else if (a < 2800) {
		cout << "ARC" << endl;
	} else {
		cout << "AGC" << endl;
	}
 }


Measured memory_bytes: 256
import sys

def comb(n, r):
    if r > n or r < 0: return 0
    r = min(r, n - r)
    if r == 0: return 1
    if r == 1: return n
    numerator = list(range(n-r+1, n+1))
    denominator = list(range(1, r+1))
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result

def solve(n, k):
    if k == 0:
        return 1

    p = int(str(n)[0])
    l = len(str(n))
    if l < k:
        return 0
    res = 0
    for r in range(k-1, l-1):
        res += comb(r, k-1) * 9 ** (k - 1) * 9
    res += comb(l-1, k-1) * 9 ** (k - 1) * (p - 1)
    if k == 1:
        res += 1
    else:
        res += solve(int(str(n)[1:]), k-1)
    return res

n, k = map(int, sys.stdin.read().split())
def main():
    return solve(n, k)

if __name__ == '__main__':
    ans = main()
    print(ans)

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  cout << (a-c)/(b+c)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
	int X;
	cin >> X;
	if(X%5==0 || X%7 == 0){
	cout << "YES" << endl;
	}
	else if(X%3 == 0 && X%6!=0 && X%9 != 0){
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
signed main()
{   
      senky_bansal
      IIIT_ALLAHABAD
      
     ll n,d;
     cin>>n>>d;
     ll ans=0;
     int p=1+d;
     while(p<=n)
     {
        ans++;
        p+=2*d+1;
     }
     p-=(2*d+1);
     if(p+d<n)
     ans++;
     cout<<max(1LL,ans);
}
















Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#ifdef TEST
struct test {
    int ans;
} td[] = {
    {},
};
#endif

void
solver(long n, int k)
{
    long d;

    d = 1;
    while(n >= k) {
        d++;
        n = n / k;
    }
    printf("%ld\n", d);
}

int
main(int argc, char *argv[])
{
#ifdef TEST
    int tt;
    for(tt = 0; tt < sizeof(td) / sizeof(struct test); tt++) {
        solver();
        printf("%d\n", td[tt].ans);
    }
#endif
    long N;
    int K;
    scanf("%ld%d", &N, &K);
    solver(N, K);
    return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int n,m;cin>>n>>m;
  int mx_l=0, mn_r=n+100;
  for(int i=0;i<m;i++){
    int l,r;cin>>l>>r;
    mx_l = max(l, mx_l);
    mn_r = min(r, mn_r);
  }

  if(mx_l>mn_r)cout<<0<<endl;
  else cout<<(mn_r-mx_l+1)<<endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  cin >> N;
  ll max_idx = -1;
  ll maxv = -1;
  vector<ll> list(N);
  for (int i = 0; i < N; i++) {
    cin >> list[i];
    if (maxv < abs(list[i])) {
      maxv = abs(list[i]);
      max_idx = i;
    }
  }

  vector<pair<ll, ll> > hist;
  for (int i = 0; i < N; i++) {
    list[i] += list[max_idx];
    hist.push_back(make_pair(max_idx + 1, i + 1));
  }

  if (list[max_idx] >= 0) {
    for (int i = 0; i < N - 1; i++) {
      list[i + 1] += list[i];
      hist.push_back(make_pair(i + 1, i + 2));
    }
  } else {
    for (int i = N - 1; i > 0; i--) {
      list[i - 1] += list[i];
      hist.push_back(make_pair(i + 1, i));
    }
  }

  cout << hist.size() << endl;
  for (auto itr = hist.begin(); itr != hist.end(); itr++) {
    cout << itr->first << " " << itr->second << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

void solve(string s){
    int id = 0, nxt = 1;
    int zen = 0, aku = 0;
    for (auto &&i : s) (i == 'o' ? zen : aku)++;
    if(zen < aku){
        puts("-1");
        return;
    }else if(zen == aku){
        for (int i = 0; i < s.size(); i += 2) {
            if(s[i]^s[i+1]^'o'^'x') {
                puts("-1");
                return;
            }
        }
        cout << s.size()/2-1 << "\n";
        for (int i = 0; i+2 < s.size(); i += 2) {
            printf("split %d %d\n", i, 1);
        }
        return;
    }
    vector<tuple<int, int, int>> ans;
    while(s.size() > 2){
        if(all_of(s.begin(),s.end(), [&](char c){ return c == 'o'; })){
            ans.emplace_back(0, id, 0);
            s = s.substr(1, s.size());
            id = nxt++;
            id = nxt++;
            continue;
        }
        if(!(s[0]^s[1]^'o'^'x')){
            ans.emplace_back(0, id, 1);
            s = s.substr(2, s.size());
            id = nxt++;
            id = nxt++;
            continue;
        }
        if(!(s.back()^s.end()[-2]^'o'^'x')){
            ans.emplace_back(0, id, s.size()-3);
            s = s.substr(0, s.size()-2);
            id = nxt++;
            nxt++;
            continue;
        }
        if(s.front() == 'o'){
            ans.emplace_back(0, id, 0);
            ans.emplace_back(1, nxt+1, nxt);
            id = nxt+2;
            nxt = nxt+3;
            s = s.substr(1, s.size())+'o';
        }else if(s.back() == 'o') {
            ans.emplace_back(0, id, s.size()-2);
            ans.emplace_back(1, nxt+1, nxt);
            s = 'o'+s.substr(0, s.size()-1);
            id = nxt+2;
            nxt = nxt+3;
        }else {
            int cur = 0, cnt = 0;
            for (int i = 0; i < s.size(); ++i) {
                cnt += (s[i] == 'o' ? 1 : -1);
                if(cnt == 1) {
                    cur = i;
                    break;
                }
            }
            ans.emplace_back(0, id, cur);
            ans.emplace_back(1, nxt+1, nxt);
            rotate(s.begin(), s.end()-cur, s.end());
            id = nxt+2;
            nxt = nxt+3;
        }
    }
    cout << ans.size() << "\n";
    for (auto &&j : ans) {
        int a, b, c; tie(a, b, c) = j;
        if(a == 0) printf("split %d %d\n", b, c);
        else printf("join %d %d\n", b, c);
    }
}

int main() {
    int q;
    cin >> q;
    while(q--){
        string s;
        cin >> s;
        solve(s);
    }
    return 0;
}


Measured memory_bytes: 3284
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long ans = (x / 11) *2;
        if(x % 11 > 6) ans += 2;
        else if(x % 11 > 0) ans += 1;

        System.out.println(ans);
        sc.close();
    }

}


Measured memory_bytes: 23764
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<long long> a(n+1);
    for (int i = 0; i <= n; ++i) cin >> a[i];
    vector<long long> s(n + 1);
    s[n] = a[n];
    for (int i = n - 1; i >= 0; --i)
    {
        s[i] = s[i + 1] + a[i]; 
    }
    vector<long long> b(n+1);
    b[0] = 1 - a[0];
    b[n] = 0;
    if (b[0] < 0)
    {
        cout << -1 << endl;
        return 0;
    }
    if (n == 0 && a[0] == 1)
    {
        if (a[1] == 0)
        {
            cout << 1 << endl;
            return 0;
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }
    }
    for (int i = 1; i < n; ++i)
    {
        b[i] = (std::min)(2 * b[i - 1] - a[i], s[i + 1]);
        if (b[i] < b[i - 1] - a[i])
        {
            cout << -1 << endl;
            return 0;
        }
    }
    if (a[n] > 2 * b[n - 1] || a[n] < b[n - 1])
    {
        cout << -1 << endl;
        return 0;
    }
    long long ans = 0;
    for (int i = 0; i < n + 1; ++i)
    {
        ans += a[i] + b[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"#%d (%s) = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

const int iinf = 1e9+10;
const ll inf = 1ll<<60;
const ll mod = 998244353 ;


void GG(){cout<<"0\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b,mo) % mo;
}

const int maxn = 1e6+5;

ll dp[3003][3003];
int a,b,c,d;

signed main(){
    IOS();
    cin>>a>>b>>c>>d;
    dp[a][b] = 1;
    for (int i = a; i<=c; ++i) {
        for (int j = b; j<=d; ++j) {
            if (i == a && j == b) continue;
            if (i == a) {
                dp[i][j] = dp[i][j-1] * a % mod; continue;
            }
            if (j == b){
                dp[i][j] = dp[i-1][j] * b % mod; continue;
            }
            dp[i][j] = (j) * dp[i-1][j] + (i) * dp[i][j-1] - (dp[i-1][j-1] * (ll)((i-1) * (ll)(j-1) % mod )) % mod;
            dp[i][j] %= mod;
        }
    }
    cout<<dp[c][d]<<endl;


}


Measured memory_bytes: 73992
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;

ll powll(ll base,ll exp) { ll res = 1; while(exp>0){ if(exp & 1)res = res * base; base = base * base; exp >>= 1; } return res;}
ll mod_pow(ll base,ll exp) { ll res = 1; while(exp>0){ if(exp & 1)res = res * base % mod; base = base * base % mod; exp >>= 1; } return res % mod;}

ll modinv(ll a) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}


class MComb {
public:
   vector<ll> fact;
   vector<ll> inversed;
   MComb(int n) { // O(n+log(mod))
       fact = vector<ll>(n+1,1);
       for (int i = 1; i <= n; i++) fact[i] = fact[i-1]*i%mod;
       inversed = vector<ll>(n+1);
       inversed[n] = mod_pow(fact[n],(mod-2));
       for (int i = n - 1; i >= 0; i--) inversed[i]=inversed[i+1]*(i+1)%mod;
    }
    ll ncr(int n, int r) {
        if (n < r) return 0;
        if (n < 0 || r < 0) return 0;
       return (fact[n] * inversed[r] % mod * inversed[n-r] % mod);
    }
    ll npr(int n, int r) {
        if (n < r) return 0;
        if (n < 0 || r < 0) return 0;
       return (fact[n] * inversed[n-r] % mod);
    }
    ll nhr(int n, int r) {
       assert(n+r-1 < (int)fact.size());
       return ncr(n+r-1, r);
    }
    ll fac(int n) {
       if(n < 0)return 0;
       return fact[n];
    }
};
MComb comb(200000);
 
ll ncr(int n, int r) {
   ll res = 1;
   for (int i = n - r + 1; i <= n; i++) res = res * i % mod;
   for (int i = 1; i <= r; i++) res = res * modinv(i) % mod;
   return res;
}

int main()
{
    int n, a, b; cin >> n >> a >> b;
    ll res = (mod_pow(2, n) - ncr(n, a) - ncr(n, b)-1) % mod;
    res = (res + mod) % mod;
    cout << res << endl;

}

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

int main()
{
    int n;
    cin >> n;
    bool adj[n][n];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            adj[i][j] = false;
    for (int i = 0; i < n; i++)
    {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++)
        {
            int v;
            cin >> v;
            adj[u - 1][v - 1] = true;
        }
    }

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            cout << (adj[i][j] ? 1 : 0);
            if (j != n - 1)
                cout << ' ';
        }
        cout << endl;
    }
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin) ;
        freopen("output.txt" , "w" , stdout) ;
    #endif
    int n;
    string a;
    cin>>n>>a;
    if(n>=a.length())
        cout<<a;
    else
    {
        cout<<a.substr(0,n)<<"...";
    }
    return 0;
}

Measured memory_bytes: 3644
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

ep = p[:X]
eq = q[:Y]
epq = ep + eq
epq.sort()

ans = sum(epq)
for i, mr in enumerate(r):
    if i >= len(epq):
        break

    if mr > epq[i]:
        ans += mr-epq[i]
    else:
        break

print(ans)


Measured memory_bytes: 105580
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
#define coutv(v) for (int i = 0; i < (v).size(); ++i) cout << v[i] << ' '; cout << endl;
#define coutvv(v) for (int i = 0; i < (v).size(); ++i) {for (int j = 0; j < (v[i]).size(); ++j) cout << v[i][j] << ' '; cout << endl;}
#define debugv(v) {for (int i = 0; i < (v).size(); ++i) cerr << v[i] << ' '; cerr << endl;}
#define debugvv(v) {for (int i = 0; i < (v).size(); ++i) {for (int j = 0; j < (v[i]).size(); ++j) cerr << v[i][j] << ' '; cerr << endl;}}
#define TC int TESTCASE; cin >> TESTCASE; while (TESTCASE--)
typedef long long ll;


int main() {
	int n;
	cin >> n;
	string a;
	cin >> a;
	int cnt = 1;
	for (int i = 1; i < n; ++i)
	{
		if (a[i] != a[i-1]) {
			cnt += 1;
		}
	}
	cout << cnt;
}
 


Measured memory_bytes: 3740
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
long long a[88];
int n;
int main(){
    scanf("%d",&n);
    a[1]=1,a[0]=2;
    for(int i=2;i<=n;i++)a[i]=a[i-1]+a[i-2];
    printf("%lld",a[n]);
    return 0;
}


Measured memory_bytes: 256
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c=split(readline())
    println(uppercase(join([a[1],b[1],c[1]])))
end
main()

Measured memory_bytes: 115608
li = list(map(int,input().split()))
li = li + list(map(int,input().split()))
li = li + list(map(int,input().split()))
a = li.count(1)
b = li.count(2)
c = li.count(3)
d = li.count(4)
if 1<=a<=2 and 1<=b<=2 and 1<=c<=2 and 1<=d<=2:
    print("YES")
else:
    print("NO")

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){

    int n,k;
    cin>>n>>k;

    ll ans=0;
    repa(i,k,n+2){
        ans=(ans+((((ll)i)*(n+1-i)+1)%MOD))%MOD;
        // cerr<<"i="<<i<<" ans="<<ans<<"\n";
    }

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

Measured memory_bytes: 3636
<?php
list($n) = ints();
$max = (int) (sqrt($n / 3) + 1);
for ($i = 1; $i <= $n; ++$i) {
    $ans[$i] = 0;
    for ($x = 1; $x <= $max; ++$x) {
        for ($y = $x; $y <= $max; ++$y) {
            if ($x ** 2 + $y ** 2 + 1 + $x * $y + $x + $y > $n) break 2;
            $t = ($x + $y) ** 2 - 4 * ($x ** 2 + $y ** 2 + $x * $y - $i);
            if ($t > 0 && ((int) (sqrt($t))) ** 2 === $t && (int) sqrt($t) >= 2 + $x + $y) {
                $z = intdiv(((int) sqrt($t) - ($x + $y)), 2);
                if ($z < $y) break;
                $cnt = count(array_unique([$x, $y, $z]));
                if ($cnt === 1) {
                    ++$ans[$i];
                } elseif ($cnt === 2) {
                    $ans[$i] += 3;
                } else {
                    $ans[$i] += 6;
                }
            }
        }
    }
}
echo implode(PHP_EOL, $ans);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 16392
n = int(input())
csf = [list(map(int,input().split())) for _ in range(n-1)] # csf[N-1][csf]
for i in range(n):
    t = 0
    for j in range(i,n-1):
        if t < csf[j][1]:
            t = csf[j][1]
        elif t % csf[j][2] == 0:
            pass # tのまんま
        else:
            t = t + csf[j][2] - t % csf[j][2]
        t += csf[j][0]
    print(t)

Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int a, b, c, x;

int calc()
{
    int patterns = 0;
    for (int i = 0; i <= a; i++) {
        if (500 * i > x) break;
        for (int j = 0; j <= b; j++) {
            if (500 * i + 100 * j > x) break;
            for (int k = 0; k <= c; k++) {
                int total = 500 * i + 100 * j + 50 * k;
                if (total == x) {
                    patterns += 1;
                } else if (total > x) {
                    break;
                }
            }
        }
    }
    return patterns;
}

int main()
{
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;

    cout << calc() << endl;
}


Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const lines = input.trim().split('\n');

while (line = lines.shift()) {

    const numbers = line.split(' ').map(Number);
    // Edit from here

    if(numbers.length > 1){
        let keys = [...numbers.keys()]
        let nearest = Math.max(...numbers) - Math.min(...numbers) + 1;
        let result = [];
        for(let key = 0, lngth = numbers.length; key < lngth; key++){

            for(let innerKey = key + 1; innerKey < lngth; innerKey++){
                if( (Math.abs(numbers[keys[key]] - numbers[keys[innerKey]])) < nearest){
                    result = [numbers[keys[key]], numbers[keys[innerKey]]];
                    nearest = (Math.abs(numbers[keys[key]] - numbers[keys[innerKey]]));
                }
            }
            
        }
        if(result.length === 2){
            const [first, sec] = result
            var res = [first > sec ? first - sec : sec - first ]
        }
        console.log(res.toString())
    }
    // to here
}



Measured memory_bytes: 20336
t = sorted(list(map(int, input().split())))
mod = 10**9 + 7
X = t[0]
Y = t[1]
xy = 0

while X >= 0:
    if Y == 2*X:
        break
    X -= 3
    Y -= 3
    xy += 1
#print(X, Y, xy)

if X < 0:
    print("0")
else:
    ans = 1
    for i in range(xy):
        ans = (ans * (X + 2 * xy - i) * pow(i + 1, -1, mod)) % mod
    print(ans)

Measured memory_bytes: 9184
import itertools
import copy

H, W, K = map(int, input().split())
C = [list(input()) for i in range(H)]
clist = list(itertools.product([0, 1], repeat=H+W))
        
ans = 0
for q in clist:
  black = 0
  h = q[:H]
  w = q[H:]
  for i in range(H):
    for j in range(W):
      if h[i] == w[j] == 0 and C[i][j] == '#':
        black += 1
  if black == K:
    ans += 1
    #print(q)

print(ans)


Measured memory_bytes: 9436
#!/usr/bin/python3
# vim: set fileencoding=utf-8:
import sys
input = sys.stdin.readline

"""
H = int(input())
h = [int(ele) for ele in input().split()]
h = [0] + h
"""


def main():
    N, A, B = map(int, input().split())
    print(min(B, N*A))


def bfs(queue):
    global yet, graph
    if len(queue) == 0:
        return
    yet.remove(queue[-1])

    for i, adjacency in enumerate(graph[queue[-1]]):
        if adjacency == 1 and (i in yet) and (i not in queue):  # 隣接かつ未探索であれば、stackにpush
            queue.appendleft(i)
    else:
        queue.pop()
        bfs(queue)


def dfs(stack):
    global yet, graph
    yet.remove(stack[-1])

    for i, adjacency in enumerate(graph[stack[-1]]):
        if adjacency == 1 and i in yet:  # 隣接かつ未探索であれば、stackにpush
            stack.append(i)
            dfs(stack)
    else:
        stack.pop()


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
        if i != n // i:
            divisors.append(n//i)
    return divisors


class Node():

    def __init__(self):
        self.idx = None
        self.left = None
        self.right = None
        self.parent = None
        return

    def pre_order(self):
        global pre_order_str
        pre_order_str += str(self.idx) + " "
        if self.left:
            self.left.pre_order()

        if self.right:
            self.right.pre_order()

    def in_order(self):
        global in_order_str

        if self.left:
            self.left.in_order()

        in_order_str += str(self.idx) + " "

        if self.right:
            self.right.in_order()

    def post_order(self):
        global post_order_str
        if self.left:
            self.left.post_order()

        if self.right:
            self.right.post_order()

        post_order_str += str(self.idx) + " "


class HeapHelper():
    """HeapContrler.
    完全二分木を二分ヒープで表現した配列 A に対して、
    HeapHelper.parent(idx) とするとそのノードの親の添字を返す
    存在しない場合は Falseを返す

    Returns:
        [type] -- [description]
    """

    def __init__(self):
        return

    @staticmethod
    def parent(i):
        if i == 1:
            return False

        return int(i/2)

    @staticmethod
    def left(i):
        l_idx = 2*i
        if H < l_idx:
            return False

        return l_idx

    @staticmethod
    def right(i):
        r_idx = 2*i + 1
        if H < r_idx:
            return False

        return r_idx


if __name__ == "__main__":
    main()


Measured memory_bytes: 3192
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

struct Ville {
    large x, y;
    large p;

    large near_x, near_y;
};

int nx;
int xs[20];
int ny;
int ys[20];

static large solve(Ville* const v, const int n, const int start, const int k) {
    if (k == 0) {
        auto sum = 0LL;
        for (int i = 0; i < n; ++i) {
            auto xmin = LLONG_MAX; // 南北の鉄道のいずれかからの最短距離
            auto ymin = LLONG_MAX; // 東西の鉄道のいずれかからの最短距離
            for (int ix = 0; ix < nx; ++ix)
                xmin = min(xmin, abs(v[i].x - xs[ix]));
            for (int iy = 0; iy < ny; ++iy)
                ymin = min(ymin, abs(v[i].y - ys[iy]));
            sum += v[i].p * min(xmin, ymin);
        }
        return sum;
    }

    auto score = LLONG_MAX;
    for (int i = start; i + k <= n; ++i) {
        // 南北の鉄道のx座標
        xs[nx++] = v[i].x;
        auto case1 = solve(v, n, i + 1, k - 1);
        nx--;
        // 東西の鉄道のy座標
        ys[ny++] = v[i].y;
        auto case2 = solve(v, n, i + 1, k - 1);
        ny--;

        score = min({score, case1, case2});
    }
    return score;
}

int main()
{
    int n;
    cin >> n;
    auto ville = vector<Ville>();
    for (auto i = 0; i < n; ++i) {
        auto v = Ville{};
        cin >> v.x >> v.y >> v.p;
        ville.push_back(v);
    }


    xs[nx++] = 0;
    ys[ny++] = 0;
    for (int k = 0; k < n; ++k) {
        cout << solve(ville.data(), n, 0, k) << "\n";
    }

    for (int k = n; k <= n; ++k) {
        cout << "0\n";
    }

    return 0;
}


Measured memory_bytes: 3576
#include<iostream>
#include<cstdio>
#include<vector>

using namespace std;
vector<int> G;
void shellSort(int*,int);

long long cnt = 0;
int A[1000000];
int n;

int main(void){
    cin>>n;
    for(int i=0;i<n;++i){
        scanf("%d",A+i);
    }
    cnt=0;
    shellSort(A,n);
    cout<<G.size()<<endl;
    for(int i=G.size()-1;i>=0;--i){
        cout<<G[i];
        if(i) cout<<" ";
    }
    cout<<endl;
    cout<<cnt<<endl;
    for(int i=0;i<n;++i){
        cout<<A[i]<<endl;
    }
    return 0;
}

void shellSort(int* addr, int n){
    void insertionSort(int*,int,int);
    for(int h=1;;){
        if(h>n) break;
        G.push_back(h);
        h = 3*h+1;
    }
    for(int i=G.size()-1;i>=0;--i){
        insertionSort(addr,n,G[i]);
    }
}

void insertionSort(int* addr, int n, int g){
    for(int i=g;i<n;++i){
        int v = addr[i];
        int j = i - g;
        while(j>=0 && addr[j]>v){
            addr[j+g]=addr[j];
            j -= g;
            cnt++;
        }
        addr[j+g] = v;
    }
    return;
}








Measured memory_bytes: 7132
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define first fst
#define second scd

#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long


signed main(){
  int a[3];
  int cnt=0;
  cin>>a[0]>>a[1]>>a[2];
  int sum=a[0]+a[1]+a[2];
  while(a[0]!=a[1] || a[1]!=a[2]){
    int target=(sum+((cnt+1)*2))/3;
    sort(a,a+3);
    if(a[2]<target){
      a[2]++;
      a[1]++;
    }else if(a[1]<target){
      a[1]++;
      a[0]++;
    }else{
      a[0]+=2;
    }
    cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,nt,n,t,j,p=0;
    set<int>se;

    string s;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>p;
        se.insert(p);
    }
    if(n==se.size()){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}




Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(150) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  //[0,N),[N,2N),[2N,3N)
  Vec(P,lli,3*N,0);
  rep(i,0,3*N)cin >> P[i];
  Sort(P);
  rep(i,N,2*N)sum+=P[i];
  rep(i,N,3*N){num+=P[i];i++;}
  Out(max(num,sum));
}

Measured memory_bytes: 2560
import java.util.*;

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

        int[][] c = new int[3][3];

        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                c[i][j] = sc.nextInt();
            }
        }
        int[][] d = new int[3][2];

        for(int i=0; i<3; i++){
            for(int j=0; j<2; j++){
                d[i][j] = c[i][j + 1] - c[i][j];
            }
        }
        if(d[0][0]==d[1][0] && d[1][0]==d[2][0] && d[0][1]==d[1][1] && d[1][1]==d[2][1]){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    vector<int> table(100100,0);
    REP(i,N){
        int a; cin >> a;
        table[a] ++;
    }

    int ans = 0;
    FOR(i,1,100000){
        ans = max(ans, table[i-1]+table[i]+table[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3752
s = int(input())
a = [s]

for i in range(1,1000000):
    tmp = 0
    if(a[i-1]%2 == 0):
        tmp = a[i-1]//2
    else:
        tmp = 3*a[i-1]+1
    
    a.append(tmp)
    if(a.count(tmp) >=2 ):
        print(i+1)
        break

    


Measured memory_bytes: 38384
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]
dp = [[0] * N for _ in range(2)]
dp[0][0] = A[0][0]
for i in range(2):
  for j in range(N):
    if i == 0:
      dp[i + 1][j] = max(dp[i][j] + A[i + 1][j], dp[i + 1][j])
    if j < N - 1:
      dp[i][j + 1] = max(dp[i][j] + A[i][j + 1], dp[i][j + 1])
print(dp[1][-1])

Measured memory_bytes: 38256
#include<cstdio>
#include<utility>
using namespace std;

int t1, t2;
long a1, a2, b1, b2;

int main() {
    scanf("%d %d", &t1, &t2);
    scanf("%ld %ld", &a1, &a2);
    scanf("%ld %ld", &b1, &b2);
    
    if ((a1 > b1 && a2 > b2) || (a1 < b1 && a2 < b2)) {
        printf("0\n");
        return 0;
    }
    if (a1 < b1 && a2 > b2) {
        swap(a1, b1);
        swap(a2, b2);
    }
    long m = (a1 - b1) * t1;
    long n = (b2 - a2) * t2;
    if (m > n) {
        printf("0\n");
    }
    else if (m == n) {
        printf("infinity\n");
    }
    else {
        printf("%ld\n", (m % (n - m) == 0) ? m / (n - m) * 2 : m / (n - m) * 2 + 1);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int sum=0;
  cin >> N;
  for(int i=0;i<N;i++){
    string a;
    cin >> a;
    if(a=="Y")
      sum=1;
  }
  if(sum==0)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
		
      switch (a) {
        case 22:
            System.out.println("Christmas Eve Eve Eve");
            break;
        case 23:
            System.out.println("Christmas Eve Eve");
            break;
        case 24:
            System.out.println("Christmas Eve");
            break;
        case 25:
            System.out.println("Christmas");
            break;
        }
    }
}

Measured memory_bytes: 21844
n = int(input())
a = list(map(int,input().split()))
ami = [a[i]-(i+1) for i in range(n)]
ami.sort()
# print(ami)
ans = 0
if n % 2 == 1:
    for i in range(n):
        ans += abs(ami[i]-ami[n//2])
else:
    cnt1 = 0
    cnt2 = 0
    for i in range(n):
        cnt1 += abs(ami[i]-ami[n//2])
        cnt2 += abs(ami[i]-ami[n//2-1])
    ans = min(cnt1,cnt2)
print(ans)


Measured memory_bytes: 99924
/**
 * Created by hiramekun at 20:51 on 2020-04-04.
 */
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int main() {
    ll k;
    cin >> k;
    vector<ll> a;
    for (ll i = 1; i <= 9; ++i) a.emplace_back(i);

    while (k > a.size()) {
        k -= a.size();
        vector<ll> old = a;
        a = vector<ll>();
        for (ll x: old) {
            for (ll i = -1; i <= 1; ++i) {
                ll d = x % 10 + i;
                if (d < 0 || 9 < d) continue;
                ll nx = x * 10 + d;
                a.emplace_back(nx);
            }
        }
    }
    cout << a[k - 1] << '\n';
    return 0;
}

Measured memory_bytes: 2164
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
map<ll,ll> counter;
ll fastexpo(ll x,ll y,ll m)
{
	ll temp=1;
	while(y>0)
	{
		if(y&1)temp = ((temp%m)*(x%m))%m;
		x = ((x%m)*(x%m))%m;
		y>>=1;
	}return temp;
}
void fff()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ra = 0, rw = 0, la = 0, lw = 0;
	FOR(i,0,n)
	{
		if(s[i] == 'W')rw++;
		else ra++;
	}

	int ans = n, co1, co2, co3;
	ans = min(ans, ra);
	ans = min(ans, rw);
	FOR(i,0,n)
	{
		if(s[i] =='W')lw++, rw--;
		else la++, ra--;
		co1 = min(lw,ra);
		ans = min(ans, lw + ra - co1);
	}
	cout << ans<<ln;
}	
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

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

Measured memory_bytes: 3596