akhauriyash/Code-Regression huggingface dataset:
listS=list(input())
odd1=0
odd0=0
even1=0
even0=0
index=0
while index < len(listS):
    if index%2==0:
        if listS[index]=="1":
            even1+=1
        else:
            even0+=1
    else:
        if listS[index] == "1":
            odd1 += 1
        else:
            odd0 += 1
    index+=1

print(min(even0+odd1, even1+odd0))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x){ if(x <= 1) return false; for(ll i = 2; sqrt(i) <= x; i++) if(x % i == 0) return false; return true; }


int main() {
    int n,r;
    cin >> n >> r;
    int l;
    l = 100*(10-n);
    if(n >= 10){
        cout << r << endl;
    }else{
        cout << r + l << endl;
}
  

    return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<char>>();

    let mut count = 0;
    for c in s {
        if c == '+' {
            count += 1;
        } else {
            count -= 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper

n  =inp()
a = inp()
if a >= n %500:
    print('Yes')
else:print('No')


Measured memory_bytes: 3700
#include <cstdio>

int main() {
    int N[4];
    int M[] = {1,9,7,4};
    int  i, j;
    scanf("%d %d %d %d",&N[0],&N[1],&N[2],&N[3]);
    for (i=0; i<4; i++) {
        for (j=0; j<4; j++) {
            if (N[i] == M[j]) {
                M[j] = 10;
                j == 0;
                break;
            }
        }
        if (j == 4) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, a, b) for(int i = a; i < (int)(b); ++i)

int board[100000];
vector<int> v[100000];
int main(void)
{
	int N;
	cin >> N;


	Rep(i, N - 1){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	vector<int> vf;
	vector<int> vs;
	board[0] = 1;
	vf.push_back(0);
	board[N - 1] = -1;
	vs.push_back(N - 1);

	while(1){
		int break_count = 0;
		if(vf.size() != 0){
			vector<int> vt;
			for(auto &x: vf){
				for(auto &y: v[x]){
					if(board[y] == 0){
						board[y] = 1;
						vt.push_back(y);
					}
				}
			}
			vf = vt;
		}else{
			break_count++;
		}
		if(vs.size() != 0){
			vector<int> vt;
			for(auto &x: vs){
				for(auto &y: v[x]){
					if(board[y] == 0){
						board[y] = -1;
						vt.push_back(y);
					}
				}
			}
			vs = vt;
		}else{
			break_count++;
		}
		if(break_count == 2) break;
	}

	int count = 0;
	Rep(i, N){
		count += board[i];
	}
	if(count > 0){
		PrintLn("Fennec");
	}else{
		PrintLn("Snuke");
	}
	return 0;
}


Measured memory_bytes: 6440
while True:
    try:
        l_v = list(map(int, input().split(',')))
    except:
        break
    l = l_v[0:10]
    station = [0]
    for i in range(10):
        station.append(l[i]+station[i])
    S = station[10]
    v1 = l_v[10]
    v2 = l_v[11]
    t = S / (v1 + v2)
    v1s = v1 * t
    for i in range(10):
        if station[i] < v1s <= station[i+1]:
            print(i+1)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[55];
int main(){
    int n,num=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=1;i<=n;i++){
        if(a[i]!=i) num++;
    }
    if(num==2||num==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

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

int main(){
    int n,x,t;
    cin >> n >> x >> t;
    int ans;
    if(n%x == 0) ans = t*(n/x);
    else ans = t*(n/x+1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
import sys
sys.setrecursionlimit(10**7)

def get_cost(arr, n, k, dp):
  min_ = -1
  for i in range(2, n):
    dp[i] = min([(abs(arr[s] - arr[i]) + dp[s]) for s in range(max(0, i-k), i)])
  return dp[-1]
    

N, K = input().split()
N = int(N)
K = int(K)
arr = [int(num) for num in input().split()]

dp = [0]*N
dp[1] = abs(arr[1] - arr[0])
print(get_cost(arr, N, K, dp))

Measured memory_bytes: 14260
//#define LOCAL 
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <ctype.h>
#include <sstream>
#include <iomanip>
#include <fstream>   
#include <cassert>
#include <climits>

#define min(a,b) ((a)<(b) ? (a):(b))
#define max(a,b) ((a)>(b) ? (a):(b))
#define abs(a) ((a)>0 ? (a):-(a)) 

#define pb push_back
#define mp make_pair
#define st first
#define nd second

//#define ALL(x) x.begin(), x.end() 
//#define INS(x) inserter(x, x.begin())
#define REP(i,n) for(int i = 0; i < (n); i++)
#define MST(a,b) memset(a,b,sizeof(a))

const int INF = 0x3f3f3f3f;
const int N = 1010;
using namespace std;
typedef long long LL;

#define mp make_pair
#define st first
#define nd second
typedef pair<int, int> PII;

int h, w, n;
char g[N][N]; 

void read() {
	scanf("%d%d%d", &h, &w, &n);
	MST(g, 'X');
	for (int i = 1; i <= h; i++) {
		getchar();
		for (int j = 1; j <= w; j++) 
			g[i][j] = getchar();
	}
//	for (int i = 1; i <= h; i++) {
//		for (int j = 1; j <= w; j++) 
//			cout << g[i][j];
//		cout << endl;
//	}
}

int setp(int x, int y) {
	return (x-1)*w+y-1;
}

void getp(int xy, int& x, int& y) {
	x = xy/w+1;
	y = xy%w+1;
}

int pos[10], d[N][N];
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int bfs(int s) {
	MST(d, INF);
	queue<int> q;
	int sx, sy;
	getp(pos[s], sx, sy);
	q.push(pos[s]);
	d[sx][sy] = 0;
	while (q.size()) {
		int t = q.front(); q.pop();
		int tx, ty;
		getp(t, tx, ty);
//		cout << tx << " " << ty << endl;
		if (t == pos[s+1]) return d[tx][ty];
		
		for (int k = 0; k < 4; k++) {
			int txx = tx+dx[k], tyy = ty+dy[k];
			if (g[txx][tyy] == 'X') continue;
			int tt = setp(txx, tyy); 
			if (d[txx][tyy] == INF) {
				d[txx][tyy] = d[tx][ty] + 1;
				q.push(tt);
//				cout << "\t" << txx << " " << tyy << endl;
			}
		}
	}
}

int solve() {
	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++) {
			if (g[i][j] == 'S') pos[0] = setp(i, j);
			if (isdigit(g[i][j])) pos[g[i][j]-'0'] = setp(i, j);
		}
	
//	for (int i = 0; i <= n; i++) {
//		int x, y;
//		getp(pos[i], x, y);
//		cout << pos[i] << " " << x << " " << y << endl;
//	}
	
	int ans = 0;
	for (int i = 0; i < n; i++)
		ans += bfs(i);
	return ans;
}

int main() {
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	read();
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 6212
#include <bits/stdc++.h>
using namespace std;
int main(){
	char S[100100];
	scanf("%s",&S);
	char tmpc = S[0];
	int count = 0;
	for (int i = 1; S[i] != '\0'; ++i)
	{
		if(tmpc != S[i]){
			count ++;
			tmpc = S[i];
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 384
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
	string s;
	cin >> s;

	while(true) {
		bool flag = false;
		FOR(i, 3, s.size()-1) {
			if(s.substr(i-2, 3) == "mew") {
				s.erase(i-2, 3);
				flag = true;
			}
		}
		if(!flag) break;
	}

	if(s == "mew") cout << "Cat" << endl;
	else cout << "Rabbit" << endl;

	return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a[i];
  vector<int> b(n);
  for(int i=0;i<n;i++){
    if(a[i]+i<n)
      b[a[i]+i]+=1;
  }
  long long int ans=0;
  for(int i=0;i<n;i++){
    if(0<=i-a[i])ans+=b[i-a[i]];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4844
import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)

    val n, k = sc.nextInt()

    val ans =
      (1 to n)
        .map(i => {
          var j = 0
          while (i * math.pow(2, j) < k) j += 1
          math.pow(0.5, j) / n
        })
        .sum
    println(ans)
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }

  def printExecTime(process: => Unit): Unit = {
    val start = System.currentTimeMillis
    process
    debug("処理時間： " + (System.currentTimeMillis - start) + " ミリ秒")
  }

  def bitSearch[T](n: Int, choice: Vector[T]): Vector[Vector[T]] = {
    @tailrec
    def bitSearchLogic(n: Int,
                       choice: Vector[T],
                       acc: Vector[Vector[T]]): Vector[Vector[T]] = {
      if (n == 0) acc
      else {
        val newAcc =
          acc.flatMap(vec => {
            choice.map(c => vec :+ c)
          })
        bitSearchLogic(n - 1, choice, newAcc)
      }
    }

    val firstAcc = choice.map(i => Vector(i))
    bitSearchLogic(n - 1, choice, firstAcc)
  }
}


Measured memory_bytes: 40896
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <cfloat>


int main(){
    int A, B;
    int H, M;

    std::cin >> A >> B >> H >> M;

    // [1]2つの針の位置を求める 
    const double TIME_AS_MIN = H * 60 + M;
    double Adgree, Bdgree; // 12時 = 0度の360度法での各針の指す方向 
    Bdgree = (TIME_AS_MIN / (12 * 60)) * 360;
    Adgree = M * 6;
    // std::cout << Adgree << ":" << Bdgree << std::endl;
    // std::cout << abs(Bdgree - Adgree) << ":" << abs(((int)Bdgree % 180) - Adgree) << std::endl;
/*
    if(abs(Bdgree - Adgree) > abs(((int)Bdgree % 180) - Adgree)){

        if(fabs(Bdgree - 180.0) > DBL_EPSILON) Bdgree = (int)Bdgree % 180;
    }
    // std::cout << Adgree << ":" << Bdgree << std::endl;
*/
    // [2]A-Bの長さを求める 
    double ans = 0.0;
    double diff_dgree = Adgree - Bdgree;
    if(diff_dgree < 0){
        diff_dgree *= -1;
    }

    else if(fabs(diff_dgree - 180.0) <= DBL_EPSILON){
        std::cout << A + B << std::endl;
        return 0;
    }

    if(fabs(diff_dgree - 0.0) <= DBL_EPSILON){
        // 重なっている場合 
        // std::cout << "A and B is same position:";
        ans = abs(A - B);
    }else{
        double sqr_ans = (A*A) + (B*B) -(2*A*B*cos(diff_dgree * M_PI / 180));
        // std::cout << A << "|" << B << "|" << cos(diff_dgree * M_PI / 180) << std::endl;
        // std::cout << "ans^2 = " << sqr_ans << std::endl;;
        ans = sqrt(sqr_ans);
    }
    
    printf("%.20f\n", ans);

    return 0;
}

Measured memory_bytes: 4088
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int n;
    cin >> n;
    map<string, int> m;
    while (n--) {
        string s;
        cin >> s;
        m[s]++;
    }
    string q = " x ";
    string x[] = {"AC", "WA", "TLE", "RE"};
    for (i = 0; i < 4; i++) {
        cout << x[i] << q << m[x[i]] << endl;
    }
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
//#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int n;
int a[2010];
ll ans;

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> n;
    forn(i, n) cin >> a[i];
    sort(a, a+n);
    forn(i, n) for(int j = i+1; j<n; j++)
    {
        int ind = lower_bound(a+j+1, a+n, a[i]+a[j]) - a;
        ind--;
        //cout << i << " " << j << " " << ind << endl;
        ans += max(0, ind-j);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
class Dice:
    
    def __init__(self, U, S, E, W, N, D):
        self.u, self.d = U, D
        self.e, self.w = E, W
        self.s, self.n = S, N       
    
    def roll(self, commmand):
        if command == 'E':
            self.e, self.u, self.w, self.d = self.u, self.w, self.d, self.e
        elif command == 'W':
            self.e, self.u, self.w, self.d = self.d, self.e, self.u, self.w
        elif command == 'S':
            self.s, self.u, self.n, self.d = self.u, self.n, self.d, self.s
        else:
            self.s, self.u, self.n, self.d = self.d, self.s, self.u, self.n

    def rightside(self, upside, forward):
        self.structure = {self.u:{self.w: self.s, self.s: self.e, self.e: self.n, self.n: self.w},
                          self.d:{self.n: self.e, self.e: self.s, self.s: self.w, self.w: self.n},
                          self.e:{self.u: self.s, self.s: self.d, self.d: self.n, self.n: self.u},
                          self.s:{self.u: self.w, self.w: self.d, self.d: self.e, self.e: self.u},
                          self.w:{self.u: self.n, self.n: self.d, self.d: self.s, self.s: self.u},
                          self.n:{self.u: self.e, self.e: self.d, self.d: self.w, self.w: self.u}}
        
        print(self.structure[upside][forward])

U, S, E, W, N, D = [int(i) for i in input().split()]
turns = int(input())
dice1 = Dice(U, S, E, W, N, D)
for i in range(turns):
    upside, forward = [int(k) for k in input().split()]
    dice1.rightside(upside, forward)


Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 1e5 + 7;

int used[N];
vector<int> g[N]; 

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
		
	int n, m;
	cin >> n >> m;
	while (m--) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}	
	vector<int> ans = {0};
	used[0] = 1;
	while (true) {
		int v = ans.back();
		int any = 0;
		for (auto u : g[v]) {
			if (!used[u] && !any) {
				used[u] = 1;
				ans.push_back(u);
				any = 1;
				break;
			}
		}
		if (!any) {
			break;
		}
	}
	reverse(ans.begin(), ans.end());
	while (true) {
		int v = ans.back();
		int any = 0;
		for (auto u : g[v]) {
			if (!used[u] && !any) {
				used[u] = 1;
				ans.push_back(u);
				any = 1;
				break;
			}
		}
		if (!any) {
			break;
		}
	}
	cout << ans.size() << endl;
	for (auto t : ans) {
		cout << t + 1 << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 7160
n,k = map(int,input().split())
h = []
for i in range(n):
  h.append(int(input()))
  
h.sort()
submin = 789654123789654123
for i in range(n-k+1):
  submin = min(submin,h[i+k-1]-h[i])
  
print(submin)

Measured memory_bytes: 7384
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

int main()
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;

    int ans = a1 + a2 + a3;
    if (ans <= 21)
    {
        cout << "win" << endl;
    }
    else
        cout << "bust" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define pii pair<int, int>
#define f first
#define s second
using namespace std;

const int N=2e5+5, INF=1e9;

int n, a[N];
set<int> S;
vector<int> v;

struct node
{
	pii val[2];
	int lzy=0;
} segt[4*N];
void combine(int idx, int par)
{
	if(segt[idx*2].val[par].f < segt[idx*2+1].val[par].f)
	{
		segt[idx].val[par] = segt[idx*2].val[par];
		return;
	}
	segt[idx].val[par] = segt[idx*2+1].val[par];
}
void build(int idx, int l, int r)
{
	if(l==r)
	{
		segt[idx].val[l%2]={a[l], l};
		segt[idx].val[1-l%2]={INF, -1};
		//cout << idx << " " << l << " - " << segt[idx].val[1].f << endl;
		return;
	}
	int mid = (l+r)/2;
	build(idx*2, l, mid);
	build(idx*2+1, mid+1, r);
	combine(idx, 0); combine(idx, 1);
}
void lazify(int idx, int l, int r)
{
	if(segt[idx].lzy==0) return;
	else segt[idx].lzy = 0;
	swap(segt[idx].val[0], segt[idx].val[1]);
	if(l==r) return;
	segt[idx*2].lzy=1-segt[idx*2].lzy;
	segt[idx*2+1].lzy=1-segt[idx*2+1].lzy;
}
pii findmin(int idx, int ll, int rr, int ss, int ee, int pr = 0)
{
	lazify(idx, ll, rr);
	if(ll>ee || rr<ss) return {INF, -1};
	if(ll>=ss && ee>=rr)
	{
		if(pr) cout << ll << " " << rr << " - " << segt[idx].val[1].f << endl;
		return segt[idx].val[1];
	}
	int mid = (ll+rr)/2;
	pii lftnode = findmin(idx*2, ll, mid, ss, ee, pr);
	pii rtnode = findmin(idx*2+1, mid+1, rr, ss, ee, pr);
	if(lftnode.f < rtnode.f) return lftnode;
	return rtnode;
}
void flip(int idx, int ll, int rr, int ss, int ee)
{
	lazify(idx, ll, rr);
	if(ll>ee || rr<ss) return;
	if(ll>=ss && ee>=rr)
	{
		segt[idx].lzy=1-segt[idx].lzy;
		lazify(idx, ll, rr);
		return;
	}
	int mid = (ll+rr)/2;
	flip(idx*2, ll, mid, ss, ee);
	flip(idx*2+1, mid+1, rr, ss, ee);
	combine(idx, 0); combine(idx, 1);
}
void assign(int idx, int ll, int rr, int pos)
{
	lazify(idx, ll, rr);
	if(ll>pos || rr<pos) return;
	if(ll==rr)
	{
		segt[idx].val[0]=segt[idx].val[1] = {INF, -1};
		return;
	}
	int mid = (ll+rr)/2;
	assign(idx*2, ll, mid, pos);
	assign(idx*2+1, mid+1, rr, pos);
	combine(idx, 0); combine(idx, 1);
}
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	S.insert(n+1);
	build(1, 1, n);
	for(int i = 0; i < n/2; i++)
	{
		pii xx = findmin(1, 1, n, 1, n);
		int x = xx.first;
	//	cout << x << " ";
		S.insert(xx.s);
		flip(1, 1, n, xx.s+1, n);
		assign(1, 1, n, xx.s);
		auto itr = S.upper_bound(xx.s);
		int r = *itr;
	//	cout << xx.s << " " << r << " - " ;
	//	int pr = (xx.s==4);
		pii yy = findmin(1, 1, n, xx.s+1, r-1);
		int y = yy.first;
		//cout << y << endl;
		S.insert(yy.s);
		if(yy.s!=n) flip(1, 1, n, yy.s+1, n);
		assign(1, 1, n, yy.s);
		v.pb(x);
		v.pb(y);
	}
	for(auto it: v)
	{
		cout << it << " ";
	}
}

Measured memory_bytes: 25972
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;

int main() {
	long long n, m;
	cin >> n;
	m = n;
	cout << n << ":";
	for (int i = 2; i*i <= m; ++i) {
		while (n%i == 0) {
			cout << " " << i;
			n /= i;
		}
	}
	if (n != 1) { cout << " " << n; }
	cout << endl;
}


Measured memory_bytes: 3104
def main():
    alp = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L",
           "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]

    n = int(input())
    s = str(input())

    crypt = ""
    for c in list(s):
        crypt += alp[(alp.index(c) + n) % 26]

    print(crypt)


if __name__ == "__main__":
    main()


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

int main(){
  int n;
  cin >> n;
  vector<int> f; 
  ll res = 0;
  rep(i,n) {
    ll a, b;
    cin >> a >> b;
    res -= b;
    f.push_back(a+b);
  }
  sort(f.begin(), f.end(), greater<int>());
  rep(i,n) if (i%2 == 0) res += f[i];
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 892
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n"),t=Number(r[0]),n=Math.ceil(Math.sqrt(t)),o=1,u=2;u<n;u++)for(var i=1;i<n;i++){var f=Math.pow(u,i);if(f>t)break;o<f&&(o=f)}console.log(o)}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 22964
#include<bits/stdc++.h>
using namespace std;
#define rep(m,x,r) for((m)=(x);(m)<(r);(m)++)
int main(){
    int n,i,m=0;
    cin>>n;
    int a[n+1],ans[n+1];
    a[0]=-1;
    for(i=1;i<=n;i++) cin>>a[i];
    for(i=n;i>0;i--){
        if(n/i==1){//ハコが1つならそれに従う
            m+=a[i];
            ans[i]=a[i];
        }
        else{
            int buf=0;
            for(int j=2*i;j<=n;j+=i)buf+=ans[j];
            if(a[i]!=(buf%2)){
                ans[i]=1;
                m++;
            }
            else ans[i]=0;
        }
    }
        cout<<m<<endl;
        rep(i,1,n+1)if(ans[i])cout<<i<<" ";
    cout<<"\n";
}


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

using namespace std;
using ll = long long;
int c[500005], vals[500005];

int n, q, sqn;
int ans[500005];
struct query{
    int l, r, idx;
    bool operator <(const query& qu)const{
        if(l/sqn == qu.l/sqn){
            return r<qu.r;
        }
        return l/sqn<qu.l/sqn;
    }
};

vector<query> queries;


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

    cin>>n>>q;
    sqn = (int)sqrt(n);
    for(int i=0;i<n;i++){
        cin>>c[i];
    }

    for(int i=0;i<q;i++){
        int l, r;
        cin>>l>>r;
        --l;--r;
        queries.push_back({l, r, i});
    }
    sort(queries.begin(), queries.end());
    int bef_sqn = -1;
    int glob_cnt = 0;
    for(int i=0;i<q;i++){
        auto [l, r, idx] = queries[i];

        if(i==0 or queries[i-1].l/sqn != l/sqn){
            int start_pos = (queries[i].l/sqn+1)*sqn;
            memset(vals, 0, sizeof(vals));
            glob_cnt=0;
            for(int j=start_pos;j<=r;j++){
                if(!vals[c[j]]) {
                    vals[c[j]] = 1;
                    glob_cnt++;
                }
            }
        }else{
            int start_pos = (queries[i].l/sqn+1)*sqn;
            for(int j=max(start_pos, queries[i-1].r+1);j<=r;j++){
                if(!vals[c[j]]) {
                    vals[c[j]] = 1;
                    glob_cnt++;
                }
            }
        }
        int loc_cnt = 0;
        vector<int> backup;
        for(int j=l; j<=min((l/sqn+1)*sqn-1, r);j++){
            if(!vals[c[j]]) {
                vals[c[j]] = 1;
                loc_cnt++;
                backup.push_back(c[j]);
            }
        }
        ans[idx] = loc_cnt +glob_cnt;
        for(int cur: backup){
            vals[cur] = 0;
        }
    }
    for(int i=0;i<q;i++){
        cout<<ans[i]<<'\n';
    }
    return 0;
}

Measured memory_bytes: 15608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
#define EPS (1e-10)
struct Point
{
    double x, y;
    Point() {}
    Point(double _x,double _y):x(_x),y(_y) {}
    Point operator +(Point a)
    {
        return Point(x+a.x,y+a.y);
    }
    Point operator -(Point a)
    {
        return Point(x-a.x,y-a.y);
    }
    Point operator *(double d)
    {
        return Point(x*d,y*d);
    }
    Point operator /(double d)
    {
        return Point(x/d,y/d);
    }


};
double dot(Point a,Point b)
{
    return a.x*b.x+a.y*b.y;
}
double cross(Point a,Point b)
{
    return a.x*b.y-a.y*b.x;
}
double norm(Point a)
{
    return a.x*a.x+a.y*a.y;
}
double abs(Point a)
{
    return sqrt(norm(a));
}

int n;
double r;
Point p0,p1,p2,p3,p4;

Point projection(Point p1,Point p2,Point p)
{
    Point a=p2-p1;
    Point b=p-p1;
    return p1+a*dot(a,b)/norm(a);


}
void solve(Point p1,Point p2,Point p)
{
    Point p2p1=p2-p1;
    Point q=projection(p1,p2,p);
    double m=sqrt(r*r-norm(q-p0));
    Point e=p2p1/abs(p2p1);
    Point q1=q-e*m;
    Point q2=q+e*m;
    if(q1.x==q2.x)
    {
        if(q1.y<q2.y)        printf("%.6lf %.6lf %.6lf %.6lf\n",q1.x,q1.y,q2.x,q2.y);
        else  printf("%.6lf %.6lf %.6lf %.6lf\n",q2.x,q2.y,q1.x,q1.y);
    }
    else if(q1.x<q2.x) printf("%.6lf %.6lf %.6lf %.6lf\n",q1.x,q1.y,q2.x,q2.y);
    else printf("%.6lf %.6lf %.6lf %.6lf\n",q2.x,q2.y,q1.x,q1.y);
}



int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%lf%lf%lf",&p0.x,&p0.y,&r);
    scanf("%d",&n);
    while(n--)
    {
        scanf("%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y);
        solve(p1,p2,p0);
    }

    return 0;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
using namespace std;

int n,m;
string s;
int c[3][3];


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
#ifdef LOCAL_DEFINE
    FILE *stream1;
    //FILE *stream2;
    stream1=freopen("in","r",stdin);
    //stream2=freopen("out","w",stdout);
    if(stream1==NULL)return 0;
    //if(stream2==NULL)return 0;
#endif
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>c[i][j];
        }
    }
    for(int i=-10000;i<10001;i++){
        int a1=i;
        int b1=c[0][0]-a1;
        int b2=c[0][1]-a1;
        int b3=c[0][2]-a1;
        int a2=c[1][0]-b1;
        int a3=c[2][0]-b1;
        if(a2+b2==c[1][1] && a2+b3==c[1][2] && a3+b2==c[2][1] && a3+b3==c[2][2]){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
#ifdef LOCAL_DEFINE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    fclose(stream1);
    //fclose(stream2);
#endif
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N, M; cin >> N >> M;
	vector<pair<long long int, long long int>>ps;
	for (int i = 0; i < N; ++i) {
		long long int s, t; cin >> s >> t;
		ps.emplace_back(s, t);
	}
	vector<long long int>vs;

	vs.emplace_back(0);
	for (int i = 0; i < M; ++i) {
		long long int p; cin >> p;
		vs.push_back(p);
	}
	vs.emplace_back(int(1e9 + 5e7));
	sort(vs.begin(), vs.end());
	vector<long long int>sums;
	sums.emplace_back(0);
	for (int i = 0; i < M + 1; ++i) {
		if (i == 0) {
			sums.emplace_back(vs[1]);
		}
		else {

			sums.emplace_back(sums[i - 1] + vs[i + 1] - vs[i]);
		}
	}
	long long int ans = -1;
	long long int sum = 0;
	for (auto p : ps) {
		auto it = lower_bound(vs.begin(), vs.end(), p.first);
		auto jt = lower_bound(vs.begin(), vs.end(), p.second);
		if (p.first < p.second) {
			if (it == jt) {
				ans = p.second - p.first;
			}
			else if (it + 1 == jt) {
				ans = *it - p.first;
			}
			else if ((jt - it) % 2) {
				ans = (sums[jt - 1 - vs.begin()] - sums[it - vs.begin()]) + ((*it) - p.first);
			}
			else {
				ans = (sums[jt - vs.begin()] - sums[it - vs.begin()]) - ((*jt) - p.second) + ((*it)- p.first);
			}
		}
		else {
			if (it == jt) {
				ans = p.first - p.second;
			}
			else if (jt + 1 == it) {
				ans = p.first - *prev(it);
			}
			else if ((it - jt) % 2) {
				ans = (sums[it - vs.begin()] - sums[jt - 1 - vs.begin()]) - ((*it) - p.first);
			}
			else {
				ans = (sums[it - vs.begin()] - sums[jt - vs.begin()]) + ((*jt) - p.second) - ((*it) - p.first);
			}
		}
		sum += ans;
		//cout << ans << endl;
	}
	cout << sum << endl;
	return 0;
}
//
//int N, W; cin >> N >> W;
//vector<int>ws(N);
//for (int i = 0; i < N; ++i) {
//	int a; cin >> a;
//	ws[i] = a;
//}
//int dp[2][10001];

Measured memory_bytes: 7048
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    int n, a, b;
    string s;
    cin >> n >> a >> b >> s;
    int cnt = 0, cnt1 = 0;
    for (char c: s){
        if (c == 'c'){
            cout << "No\n";
        } else if (c == 'a'){
            if (cnt < a + b){
                cnt++;
                cout << "Yes\n";
            } else {
                cout << "No\n";
            }
        } else {
            if (cnt < a + b && cnt1 < b){
                cnt++, cnt1++;
                cout << "Yes\n";
            } else {
                cout << "No\n";
            }
        }
    }
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3724
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		boolean[] color = new boolean[s.length()];
		int red = 0;
		int white = 0;
		int lastwhile = -1;
		int count = 0;
		for(int i=0;i<s.length();i++){
			if( s.charAt(i) == 'W' ){
				color[i] = false;
				white++;
				lastwhile = i;
			}else{
				color[i] = true;
				red++;
			}
		}
		if( red == 0 || white == 0 ){
			System.out.println(0);
		}else{
			for(int i=0;i<red;i++){
				if( s.charAt(i) == 'R' )
				count++;
			}
			System.out.println(red-count);
		}
	}
}

Measured memory_bytes: 31584
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define all(hoge) hoge.begin(),hoge.end()
const long long INF = 1LL << 60;


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;
}

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd


int main() {
	ll n;
	cin >> n;
	vector<ll> a(n), b(n), c(n);
	rep(i, n) cin >> a[i];
	rep(i, n)cin >> b[i];
	rep(i, n)cin >> c[i];
	sort(all(a)); sort(all(b)); sort(all(c));
	vector<ll> cnta(n);
	vector<ll> cntb(n+1);
	cntb[0] = 0;
	rep(i, n) {
		cnta[i] = b.end() - upper_bound(all(b), a[i]);
		cntb[i+1] =cntb[i]+( c.end() - upper_bound(all(c), b[i]));
	}
	ll cnt = 0;
	rep(i, n) {
		cnt += cntb[n] - cntb[n - cnta[i]];
	}
	cout << cnt;
	
	return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin>>s;
    sort(s.begin(), s.end());
    if(s=="abc"){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;
using ll = long long;
ll solve() {
    string S;
    ll K;
    cin >> S >> K;
    if (all_of(S.begin(), S.end(), [&S](char c) { return c == S[0]; })) return S.size() * K / 2;
    vector<pair<char, int>> v;
    char prevc = S[0];
    int cnt = 0;
    for (int i = 0; i < S.size(); i++) {
        char c = S[i];
        if (c == prevc) cnt++;
        else {
            v.push_back(make_pair(prevc, cnt));
            cnt = 1;
        }
        prevc = c;
    }
    if (cnt != 1) v.push_back(make_pair(prevc, cnt));
    ll ans = 0;
    for (const auto& p : v) ans += p.second / 2;
    ans *= K;
    if (S.front() == S.back()) {
        int a = v.front().second;
        int b = v.back().second;
        ans -= (K - 1) * (a / 2 + b / 2 - (a + b) / 2);
    }
    return ans;
}
int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define  fi0(i,n)  for(int i=0;i<n;i++)
#define   pb()    push_back()
#define   mk()    make_pair()
#define   fst      first
#define   scnd    second
using namespace std;
int f[500], c;
void solve()
{
    int n;
    string ss;
    cin>>n >> ss;
    for(int i=0;i<ss.size();i++){
        if(ss[i]+n>90)ss[i]=ss[i]+(n-26);
        else ss[i]=ss[i]+n;
    }
    cout<<ss<<endl;
}
ll without()
{
}
void pairwise(ll n)
{

}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ///int t;cin>>t;while(t--){ solve();}
    solve();
}


Measured memory_bytes: 3628
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)
*/


f(Xs, S, M, Z) :- f(Xs, S, M, 0, Z).
f([], _, _, Z, Z).
f([X|Xs], S, M, Y, Z) :- g(X, S, M, Y, Y2), f(Xs, S, M, Y2, Z).

g(X, S, M, Y, Y2) :- X * 4 * M >= S -> Y2 is Y + 1 ; Y2 is Y.

main :-
    get_number(N, M),
    get_numbers(N, Xs),
    sum_list(Xs, S),
    f(Xs, S, M, Z),
    M =< Z -> writeln("Yes") ; writeln("No").

    % statistics(inferences, IC), writeln(IC).


Measured memory_bytes: 8048
while True:
    n, x = [int(i) for i in input().split()]

    if n == x == 0:
        break

    count = 0
    for s in range(1, n + 1):
        for m in range(s+1, n):
            for e in range(m+1, n+1):
                if x == sum([s, m, e]):
                    count += 1

    print(count)

Measured memory_bytes: 7668
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main() {
	int a, b, c, d, ans = 0;
	cin >> a >> b >> c >> d;
	bool e[110] = {}, f[110] = {};
	for (int i = a; i < b; i++)e[i] = 1;
	for (int i = c; i < d; i++)f[i] = 1;
	for (int i = 0; i <= 100; i++)if (e[i] && f[i])ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int l = s.length();
  int ans = 0,count = 0;
  for(int i=0;i<l;i++){
    if(s[i]=='R')
      count++;
    else 
      count = 0;
    ans = max(ans,count);
    }
  cout<<ans<<endl;
  }

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

using namespace std;

typedef long long ll;

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;
}

int main(void) {
    int N, K;
    cin >> N >> K;

    if (K == 1) {
        cout << 0 << endl;
        return 0;
    }

    int a = N - K;
    cout << a << endl;

    return 0;
}


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

public class Main {

	void submit() {
		int n = nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		
		long low = 2;
		long high = 2;
		
		for (int i = n - 1; i >= 0; i--) {
			int x = a[i];
			if (low % x != 0) {
				low += x - low % x; 
			}
			high -= high % x;
			if (low > high) {
				out.println(-1);
				return;
			}
			
			high += x - 1;
		}
		
		out.println(low + " " + high);
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 40028
# print('input >>')
S = input()
K = int(input())

s_left = '1'
num_1 = 0

for s in S:
    if s == '1':
        num_1 += 1
    else:
        s_left = s
        break

if K <= num_1:
    ans = '1'
else:
    ans = s_left

# print('----------output----------')
print(ans)

Measured memory_bytes: 3060
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let cs: Vec<char> = s.chars().collect();
    let mut ans = 0;
    let mut count = 0;
    for i in cs.into_iter() {
        count = match i {
            'A' | 'C' | 'G' | 'T' => count + 1,
            _ => 0,
        };
        ans = max(ans, count);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    static final int MODULUS = 1_000_000_007;

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

        int N = sc.nextInt();
        int M = sc.nextInt();

        System.out.println(solve(N, M));

        sc.close();
    }

    static int solve(int N, int M) {
        if (Math.abs(N - M) >= 2) {
            return 0;
        }

        return multiplyMod(multiplyMod(factorial(N), factorial(M)), (N == M) ? 2 : 1);
    }

    static int multiplyMod(int x, int y) {
        return (int) ((long) x * y % MODULUS);
    }

    static int factorial(int x) {
        return IntStream.rangeClosed(1, x).reduce(Main::multiplyMod).getAsInt();
    }
}

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

int main(){
    ll N,A; cin>>N>>A;
    ll L,R;
    L=A;
    R=A+N-1;

    ll eat;
    if(R<=0) eat=R;
    else if(L>=0) eat=L;
    else eat=0;

    cout<<(R+L)*(R-L+1)/2-eat<<endl;
}

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

void swap(int *a, int *b) {
    int tmp = *b;
    *b = *a;
    *a = tmp;
}  
 
int main(void) {
    int x, y, z;

    cin >> x >> y >> z;
    swap(&x, &y);
    swap(&x, &z);

    printf("%d %d %d", x, y, z);
    
    return 0;
}

Measured memory_bytes: 384
b,w=map(int,input().split())
dp=[0]*(b+w)
dp[0]=1/2
mod=pow(10,9)+7

def cmb(n,r,mod):
  if (r<0 or r>n):
    return 0
  r=min(r,n-r)
  return g1[n]*g2[r]*g2[n-r]%mod
g1=[1,1] # g1[i]=i! % mod　:階乗
g2=[1,1] # g2[i]=(i!)^(-1) % mod　:階乗の逆元
inverse=[0,1]
for i in range(2,b+w+1):
  g1.append((g1[-1]*i)%mod)
  inverse.append((-inverse[mod%i]*(mod//i))%mod)
  g2.append((g2[-1]*inverse[-1])%mod)
t1,t2=0,0
for i in range(1,1+b+w):
  t=pow(2,mod-2,mod)
  if i-b>0:
    t1*=2
    t1%=mod
    t1+=cmb(i-2,b-1,mod)
    t1%=mod
    tmp=t1*pow(2,mod-1-i,mod)
    tmp%=mod
    t-=tmp
    t%=mod
  if i-w>0:
    t2*=2
    t2%=mod
    t2+=cmb(i-2,w-1,mod)
    t2%=mod
    tmp=t2*pow(2,mod-1-i,mod)
    tmp%=mod
    t+=tmp
    t%=mod
  print(t)



Measured memory_bytes: 34464
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
typedef long long ll;


int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> sheet(n+1);
    rep(i,n) {
        cin >> a[i];
        sheet[a[i]]++;
    }
    ll tot = 0;
    for(int i=1; i<=n; i++){
        if(sheet[i]!=0) tot += sheet[i]*(sheet[i]-1)/2;
    }
    for(int i=0; i<n; i++){
        int now = sheet[a[i]];
        if(now!=0){
            cout << tot-(now-1)*now/2+(now-1)*(now-2)/2 << endl;
        }
        else{
            cout << tot << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 6428