akhauriyash/Code-Regression huggingface dataset:
n,m,k=map(int,input().split())
edge=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    edge[a].append(b)
    edge[b].append(a)
blist=[[] for i in range(n+1)]
for i in range(k):
    a,b=map(int,input().split())
    blist[a].append(b)
    blist[b].append(a)
ans=[-1]*(n+1)
for i in range(1,n+1):
    if ans[i]==-1:
        s=set([i])
        q=[i]
        while q:
            for j in edge[q.pop()]:
                if j not in s:
                    s.add(j)
                    q.append(j)
        for j in s:
            tmp=len(s)-len(edge[j])-1
            for k in blist[j]:
                if k in s:
                    tmp-=1
            ans[j]=tmp
print(" ".join(map(str,ans[1:])))

Measured memory_bytes: 102428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[][] bin;
		int N;
		int[] ans;
		bin = new int[3][3];

		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				bin[i][j]=sc.nextInt();
			}
		}
		N=sc.nextInt();
		ans =new int[N];
		for (int i = 0; i < N; i++) {
			ans[i]=sc.nextInt();
		}

		int[][] awa;
		awa = new int[3][3];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < N; k++) {

					if(bin[i][j]==ans[k]){
						awa[i][j]=0;
						break;
					}
					else{
						awa[i][j]=1;
					}

				}
			}
		}
		if (awa[0][0] == 0 && awa[0][1] == 0 && awa[0][2] == 0) {
			System.out.println("Yes");
		}
		else if (awa[1][0] == 0 && awa[1][1] == 0 && awa[1][2] == 0) {
			System.out.println("Yes");
		}
		else if (awa[2][0] == 0 && awa[2][1] == 0 && awa[2][2] == 0) {
			System.out.println("Yes");
		}
		else if (awa[0][0] == 0 && awa[1][0] == 0 && awa[2][0] == 0) {
			System.out.println("Yes");
		}
		else if (awa[0][1] == 0 && awa[1][1] == 0 && awa[2][1] == 0) {
			System.out.println("Yes");
		}
		else if (awa[0][2] == 0 && awa[1][2] == 0 && awa[2][2] == 0) {
			System.out.println("Yes");
		}
		else if (awa[0][0] == 0 && awa[1][1] == 0 && awa[2][2] == 0) {
				System.out.println("Yes");
		}
		else if (awa[0][2] == 0 && awa[1][1] == 0 && awa[2][0] == 0) {
				System.out.println("Yes");
		}
		else {
				System.out.println("No");

			}



		return;
		}
	}



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

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<long long> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	
	int mod = 1000000007;
	for (int i = 1; i < n; i++) {
		a[i] += a[i - 1];
		a[i] %= mod;
	}

	long long ans = 0;
	for (int i = 1; i < n; i++) {
		ans += a[i - 1] * b[i];
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6404
s = gets.chomp.split("")
len = s.length
hash = Hash.new(0)
len.times do |i|
  hash[s[i]] += 1
end
if [hash["a"],hash["b"],hash["c"]].max - [hash["a"],hash["b"],hash["c"]].min >= 2
  puts "NO"
else
  puts "YES"
end

Measured memory_bytes: 19164
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int k,n;
  cin>>k>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  int d=0;
  rep(i,n){
    int y=abs(a[i]-a[(i+1)%n]);
    if(i+1==n) y=k-y;
    chmax(d,y);
  }
  cout<<k-d<<endl;
  return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;

namespace P0001_ListofTop3Hills
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> list = new List<int>();

            for (int i = 1; i <= 10; i++)
            {
                list.Add(int.Parse(Console.ReadLine()));
            }

            list.Sort();

            for (int i = 9; i > 6; i--)
            {
                Console.WriteLine(list[i]);
            }

        }
    }
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> A;
  A.reserve(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  sort(A.begin(), A.end());

  vector<pair<int, int> > pairCB;
  pairCB.reserve(M);
  for (int i = 0; i < M; i++) {
    int b, c;
    cin >> b >> c;
    pair<int, int> cb = pair<int, int>(c, b);
    pairCB.push_back(cb);
  }
  sort(pairCB.rbegin(), pairCB.rend());
  
  int min_a = A[0];
  int idx = 0;
  for (int i = 0; i < M && idx < N; i++) {
    int c = pairCB[i].first;
    int b = pairCB[i].second;
    
    while(b > 0 && idx < N) {
      if (A[idx] < c) {
        A[idx] = c;
        idx++;
        b--;
      } else {
        break;
      }
    }
  }
  
  long long int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += A[i];
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1408
N = int(input())
a = [0] + [int(input()) for _ in range(N)]
x = 1
visited = set([1])
answer = 0

while True:
  x = a[x]
  if x in visited:
    answer = -1
    break
  visited.add(x)
  answer += 1
  if x == 2:
    break
    
print(answer)


Measured memory_bytes: 13724
N = int(input())
S = [None] * N

for i in range(0, N):
    S[i] = [int(s) for s in list(input())]


def local_max_level(S, N, n): # n is the starting vertex
    levels = [None] * N
    levels[n] = 0

    for l in range(0, N): # for each level l
        for i in range(0, N): # look at every vertex i
            if levels[i] == l: # which is at level l
                # scan column S[i]
                for j in range(0, N): # scan all vertices and look for adjacent vertex to i
                    if S[i][j] == 1: # vertex j is adjacent to i
                        if levels[j] == None:
                            levels[j] = l + 1

                        elif levels[j] == l - 1: continue
                        elif levels[j] == l + 1: continue
                        else:
                            return -1
    return max(levels)

def n_partite(S, N):

    M = 0
    for n in range(0, N):  # try starting with every vertex
        m = local_max_level(S, N, n)
        if m == -1: # not n-partite
            return -1
        else:
            M = max(M, m)
    return M + 1

print(n_partite(S, N))


Measured memory_bytes: 3316
#include <stdio.h>
     
int main() {
    char str[20];
    scanf("%s", str);
     
    for (int i = 0; i < 19; i++) {
    if (i == 5 || i == 13) {
        printf(" ");
        continue;
    }
    printf("%c", str[i]);
	}
    
	puts("");
    
	return 0;
    }

Measured memory_bytes: 1612
"use strict";

function main(input) {
  var lines = input.split('\n');
  var N = lines[0];
  console.log(N.split('').filter(function (x) {
    return x == 2;
  }).length);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


Measured memory_bytes: 22076
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

class Dice{
public:
  int t,s,e,n,w,b;
  Dice(){}
  Dice(int _t,int _s,int _e,int _n,int _w,int _b){
    t = _t; s = _s; e = _e; n = _n; w = _w; b = _b;
  }
  Dice moveEast(){
    return Dice(w,s,t,n,b,e);
  }
  Dice moveNorth(){
    return Dice(s,b,e,t,w,n);
  }
  Dice moveRight(){
    return Dice(t,e,n,w,s,b);
  }
};

void solve(){
}

int main(){
  int n;

  while(cin>>n,n){
    Dice d(1,2,3,5,4,6);
    int cnt = 1;

    rep(i,n){
      string s;
      cin>>s;
      if(s == "North"){
        d = d.moveNorth();
      }
      else if(s == "East"){
        d = d.moveEast();
      }
      else if(s == "West"){
        d = d.moveEast();
        d = d.moveEast();
        d = d.moveEast();
      }
      else if(s == "South"){
        d = d.moveNorth();
        d = d.moveNorth();
        d = d.moveNorth();
      }
      else if(s == "Right"){
        d = d.moveRight();
      }
      else{
        d = d.moveRight();
        d = d.moveRight();
        d = d.moveRight();
      }

      cnt += d.t;
    }

    cout<<cnt<<endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <functional>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
using namespace std;

#define rep(i,end)          rep2(i,0,(end))
#define rep2(i,beg,end)   for (int i=(beg);i<(end);i++)
#define all(cont)           begin(cont), end(cont)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll, ll> pii;
typedef pair<ll, string> pis;
typedef pair<string, ll> psi;

string gets(bool skipnewline);
vi get_n_array(int n);

void func(const int N, ll next[], ll dp[], const int k);

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a;
    cin >> a;
    cout << 3 * a*a << endl;
    return 0;
}

string gets(bool skipToNextline)
{
    if (skipToNextline) gets(false);
    const int LINE_MAX = 1024;
    char buf[LINE_MAX];
    cin.getline(buf, sizeof(buf));
    return buf;
}

vi get_n_array(int n)
{
    vi v;
    while (n-- > 0) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    return v;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <vector>
#include <algorithm> // sort
#include <map>
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    int m=20000;
    for(int i=1;i<=20000;i++){
        if(i*8/100==a&&i/10==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 256
def main():
  n=int(input())
  a= list(map(int,input().split()))
  b= list(map(int,input().split()))
  c= list(map(int,input().split()))
  ans=b[a[0]-1]
  for i in range(1,n):
    ans+=b[a[i]-1]
    if a[i]==a[i-1]+1:
      ans+=c[a[i]-2]
  print(ans)

main()

Measured memory_bytes: 8956
#include<stdio.h>

int gcd(int a, int b){
	int c = a;
	int d = b;
	int e = 0;
	/*if(a<0 || b<0){
		return -1;
	}*/
	while(d > 0){
		e = d;
		d = c%e;
		c = e;
	}
	return c;
}

int gcdThree(int a, int b, int c){
	int g;
	g = gcd(gcd(a,b), c);
	return g;
}

long long int gcdSum(int K){
	int i = 0, j, k;
	long long int g = 0;
	for(i = 1; i <= K; i++){
		for(j = 1; j <= K; j++){
			for(k = 1; k <= K; k++){
				g += gcdThree(i, j, k);
			}
		}
	}	
	return g;
}

int main(){
	int K;
	long long int ret = 0;
	scanf("%d", &K);
	ret = gcdSum(K);
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 2112
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

rslt = 0
before = -1
for i in a:
  if before == i - 1:
    rslt += b[i-1] + c[i-2]
  else:
    rslt += b[i-1]
  
  before = i

print(rslt)

Measured memory_bytes: 3064
#include <iostream>

int main() {
  int64_t a, b;
  std::cin >> a >> b;
  if (a > b) {
    int t = b;
    b = a;
    a = t;
  }

  int64_t k = (b + a) / 2;
  if (std::abs(a - k) != std::abs(b - k)) {
    std::cout << "IMPOSSIBLE" << std::endl;
  } else {
    std::cout << k << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
maxa=10**10*(-1)
N=int(input())
list1=list(map(int,input().split()))
list2=list(map(int,input().split()))
for i in range(1,N+1):
  maxa=max(sum(list1[:i])+sum(list2[i-1:]),maxa)
print(maxa)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int gcd(int a, int b) {return (b ? gcd(b, a % b) : a);}

int main(){
	int a, b, c; cin >> a >> b >> c;
	int g = gcd(a, b);
	
	cout << a * b / g / g * c << endl;
	return 0;
}



Measured memory_bytes: 3108
import Data.Functor( (<$>))

main = do
    let
	readLine = (read <$>) . words <$> getLine   ::IO [Int]

    d1 <- readLine
    d2 <- readLine
    let
	matchedState dice [top, front]
	  = filter checkFront checkList
	      where
		roll d 'S' = [d!!4, d!!0, d!!2, d!!3, d!!5, d!!1]
		roll d 'N' = [d!!1, d!!5, d!!2, d!!3, d!!0, d!!4]
		roll d 'W' = [d!!2, d!!1, d!!5, d!!0, d!!4, d!!3]
		roll d 'E' = [d!!3, d!!1, d!!0, d!!5, d!!4, d!!2]

		rolls d dirs = foldl roll d dirs

		checkTop d = top == head d
		checkFront d = front== d!!1
		rot d = rolls d "ESW"
		candidate = filter checkTop
				[ dice
				, rolls dice "S"
				, rolls dice "SS"
				, rolls dice "SSS"
				, rolls dice "E"
				, rolls dice "EE"
				, rolls dice "EEE"]
		checkList = do
		    c <- candidate
		    [c, rot c, rot.rot $ c, rot.rot.rot $ c]

	identified
	  = case matchedState d2 [d1!!0, d1!!1] of
		[]  -> False
		list -> or $ ((drop 2 d1 ==) . (drop 2)) <$> list

    putStrLn $ if identified then "Yes" else "No"



Measured memory_bytes: 3740
def edu_dp_f_lcs():
    s = input()
    t = input()
    slen = len(s)
    tlen = len(t)
    dp = [[0] * (tlen+1) for _ in range(slen+1)]
    for i in range(slen):
        for j in range(tlen):
            if s[i] == t[j]:
                dp[i+1][j+1] = dp[i][j] + 1
            else:
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])

    l = dp[slen][tlen]
    i = slen-1
    j = tlen-1
    ans = ''
    while l > 0:
        if s[i] == t[j]:
            ans = s[i]+ans
            j -= 1
            i -= 1
            l -= 1
        elif dp[i+1][j+1] == dp[i][j+1]:
            i-=1
        else:
            j-=1
    print(ans)

edu_dp_f_lcs()

Measured memory_bytes: 144592
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
double a[3000];
int main()
{
    IO;
    double j, n, m, k=0, l; int i;
    cin>>n>>m; l=m;
    for(i=1; i<=n; i++){
        cin>>a[i];  k+=a[i];
    }
    m=k/(4*m);k=0;
    for(i=1; i<=n; i++){
        if(a[i]>=m) k++;
    }
    if(k>=l) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 256
o = 998244353
r = 2500100
f = [1]
for i in range(1,r):
 f.append(f[-1]*i%o)
def v(x):
 return pow(x,o-2,o)
def c(n,k):
 return f[n]*v(f[n-k])*v(f[k])%o
n,m = map(int,input().split())
a = (c(n+3*m-1,n-1)-n*c(n+m-2,n-1))%o
if n>m+1:
 for i in range(m+1,min(3*m,n)+1):
  if (3*m-i)%2:continue
  x = (3*m-i)//2
  a = (a-c(n,i)*c(x+n-1,n-1))%o
print(a)

Measured memory_bytes: 107144
#include <iostream>
#include <string>
#include <iomanip>
#include <ios>
using namespace std;
int main(void){
  string s;
  cin >> s;
  
  int n = s.length();
  
  cout << s[0] << n - 2 << s[n-1] << endl;
  
  return 0;
}


Measured memory_bytes: 256
import itertools
N,M = list(map(int,input().split(" ")))
humans = []
points = []

for _ in range(N):
    humans.append(list(map(int,input().split(" "))))
for _ in range(M):
    points.append(list(map(int, input().split(" "))))
for human in humans:
    mindis = 10e10
    minind = -1
    a = human[0]
    b = human[1]
    for ind,point in enumerate(points):
        c = point[0]
        d = point[1]
        dist = abs(a-c) + abs(d-b)
        if mindis > dist:
            minind = ind + 1
            mindis = dist
    print(minind)


Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>

#define rep(n) for(ll i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};


signed main(){
    ll k;
    cin >> k;
    ll n;
    vector<ll> a;
    if(k == 0){
        n = 2;
        rep(2) a.pb(1);
    }else if(k == 1){
        n = 2;
        a.pb(2);
        a.pb(0);
    }else if(k <= 50){
        n = k;
        rep(k) a.pb(k);
    }else{
        n = 50;
        rep(n) a.pb(50 + (k-1)/50);
        
        if(k % 50 != 0){
            rep(50 - k%50){
                auto max_iter = max_element(all(a));
                *max_iter -= n;
                for(auto iter=a.begin();iter != a.end();++iter){
                    if(iter != max_iter){
                        (*iter)++;
                    }
                }
            }
        }
        
    }
    cout << n << endl;
    rep(n-1){
        cout << a[i] << " ";
    }
    cout << a[n-1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using intl = long long;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)((n) - 1); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define INF 1e9;
#define debug(x) cout << #x << ":" << x << endl
using namespace std;
int main(){
    intl n;
    cin >> n;
    intl x[n];
    rep(i, n){
        cin >> x[i];
    }
    sort(x, x + n);
    int min = INF;
    rep(i, 101){
        int cnt = 0;
        rep(j, n){
            cnt += (x[j] - i) * (x[j] - i);
        }
        min = min(cnt, min);
    }
    cout << min << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;

template<typename _Tp> inline void IN(_Tp &dig)
{
	char c; bool flag = 0; dig = 0;
	while (c = getchar(), !isdigit(c)) if (c == '-') flag = 1;
	while (isdigit(c)) dig = dig * 10 + c - '0', c = getchar();
	if (flag) dig = -dig;
}

LL L, R;

LL cal(LL k)
{
	if (k < 0) return 0;
	if (k % 4 == 1) return 1;
	if (k % 4 == 2) return k + 1;
	if (k % 4 == 3) return 0;
	return k;
}

int main(int argc, char const* argv[])
{
	IN(L), IN(R);
	printf("%lld\n", cal(L - 1) ^ cal(R));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[100020], n, x;
int f[100020]; // f[i] 长度为i的不下降子序列，最后一位最小是多少。
int main() {
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	memset(f, 0x3f, sizeof f);
	for (int i = 0; i < n; i++) {
		int p = lower_bound(f, f + n, a[i]) - f;//指针，返回下标p 
		f[p] = a[i];
	}
	int ans1 = lower_bound(f, f + n, 0x3f3f3f3f) - f;
	reverse(a, a + n);
	memset(f, 0x3f, sizeof f);
	for (int i = 0; i < n; i++) {
		int p = upper_bound(f, f + n, a[i]) - f;
		f[p] = a[i];
	}
	int ans2 = lower_bound(f, f + n, 0x3f3f3f3f) - f;
	printf("%d\n", ans2);
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
//<<setprecision(30)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 1000000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  ll N,M; cin>>N>>M;
  vector<ll> A(M);
  ll s = 0;
  rep(i,M){
    cin>>A.at(i);
    s+=A.at(i);
  }
  if(s>N){
    cout<<-1<<endl;
  }else cout<<N-s<<endl;
}

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

using namespace std;

int main() {
    set<int> st;

    int q;
    cin >> q;
    while (q--) {
        int op, x;
        cin >> op >> x;

        switch (op) {
            case 0:
                st.insert(x);
                cout << st.size() << endl;
                break;
            case 1:
                cout << st.count(x) << endl;
                break;
            case 2:
                st.erase(x);
                break;
        }
    }
    return 0;
}


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

const int mod = 1e9+7;
const int INF = 2000000;
const double PI = acos(-1.0);

int main() {
    ll N;
    cin >> N;
    string ans = "";
    vector<int> ch;
    char alp[26] = {'z','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'};
    while(N != 0) {
        int tmp = N%26;
        ch.push_back(tmp);
        N /= 26;
        if(tmp == 0) N--;
    }
    for(int n:ch) ans = alp[n] + ans;
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
using namespace std;
using ll = long long;
int main(){
  int a,b;
  cin >> a >> b;
  if ((a+b)%2==0){
    cout << (a+b)/2 << endl;
  }
  else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
long long a=0,b=0,x=0,c=0;
cin>>a>>b>>x;
if(a>0)	{
	
	a-=1;
	c=(b/x)-(a/x);
}
else{
	c=b/x;
	c++;
}
cout<<c;
return 0;
	
}


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

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

using namespace std;

struct Data {
  int x,y;
  bool operator < ( const Data &data ) const {
    if( x != data.x ) return x < data.x;
    return y < data.y;
  }
};

map<Data,int> mp;
const int MAX = 110000;
int xs[MAX],ys[MAX],w[MAX];

inline int getScore(int i,int dx,int dy){
  return w[i] + mp[(Data){xs[i]+dx,ys[i]}] + mp[(Data){xs[i],ys[i]+dy}] + mp[(Data){xs[i]+dx,ys[i]+dy}];
}

int main(){
  int N;
  scanf("%d",&N);
  rep(i,N){
    scanf("%d %d %d",xs+i,ys+i,w+i);
    mp[(Data){xs[i],ys[i]}] = w[i];
  }
  int maxi = 0;
  rep(i,N){
    maxi = max(maxi,max(getScore(i,-1,-1),max(getScore(i,-1,1),max(getScore(i,1,-1),getScore(i,1,1)))));
  }
  printf("%d / 1\n",maxi);
  return 0;
}

Measured memory_bytes: 58620
import java.util.Scanner;

public class Main {

	private static long sumOfgcdTuples(int k) {
		long sum = 0;
		for (int a = 1; a <= k; a++) {
			for (int b = 1; b <= k; b++) {
				for (int c = 1; c <= k; c++)
					sum += gcd(a, b, c);
			}
		}
		return sum;
	}

	private static int gcd(int a, int b, int c) {
		return gcd(a, gcd(b, c));
	}

	private static int gcd(int a, int b) {
		if (a == 1 || b == 1)
			return 1;
		else if (a % b == 0)
			return b;
		else
			return gcd(b, a % b);
	}

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			System.out.println(sumOfgcdTuples(scanner.nextInt()));
		}
	}

}


Measured memory_bytes: 35588
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int main(){
    //~ freopen("file.in", "r", stdin); 
    string s;
    cin>>s;
    if(s.find("AC")<10)
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 256
import collections
import itertools as it
import math
import numpy as np

# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()

H = int(input())

c = 0
for i in range(10000000):
    c += 1
    if H == 1:
        break
    else:
        H = H // 2

ans = 0
for i in range(c):
    ans += 2 ** i

print(ans)

Measured memory_bytes: 21628
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int a[N];
	int cnt = 0;
	rep(i, N) cin >> a[i];
	rep(i, N) {
		while (a[i] % 2 == 0) {
			cnt++;
			a[i] /= 2;
		}
	}
	cout << cnt << endl;


    return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task2 solver = new Task2();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task2 {
		public void solve(int testNumber, Scanner sc, PrintWriter out) {

			int a = sc.nextInt();
			int b = sc.nextInt();
			int k = sc.nextInt();

			int min = Math.min(a + k, b);
			for (int i = a; i < min; i++) {
				out.println(i);
			}
			for (int i = Math.max(b - k + 1, min); i <= b; i++) {
				out.println(i);
			}

		}

	}

	static class Scanner {
		private final InputStream in;
		private final byte[] buffer;
		private int ptr;
		private int buflen;

		public Scanner(InputStream in) {
			this.in = in;
			this.buffer = new byte[1024];
			this.ptr = 0;
			this.buflen = 0;
		}

		private boolean hasNextByte() {
			if (ptr < buflen) return true;
			else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) return false;
			}
			return true;
		}

		private byte readByte() {
			if (hasNextByte()) return buffer[ptr++];
			return -1;
		}

		private boolean isPrintableChar(byte c) {
			return '!' <= c && c <= '~';
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
				ptr++;
			}
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public int nextInt() {
			if (!hasNext()) throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			byte b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) throw new NumberFormatException();
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

	}
}



Measured memory_bytes: 21460
#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];
    cout<<*max_element(a.begin(),a.end())-*min_element(a.begin(),a.end());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const int mod = 1000000007;

int main() {
    int h,w; cin >> h >> w;
   vector<string> c(h);
   rep(i,h) cin >> c[i];

   rep(i,h){
       print(c[i]);
       print(c[i]);
   }
}

Measured memory_bytes: 256
const lines=readlines()
parseInt(s)=map(x->parse(Int,x),split(s))
const N,Q=parseInt(shift!(lines))
const G=[Tuple{Int,Int,Int}[] for _=1:N]
function init()
	for _=2:N
		a,b,c,d=parseInt(shift!(lines))
		push!(G[a],(b,c,d))
		push!(G[b],(a,c,d))
	end
end
init()
const depth=zeros(Int,N)
const parent=[zeros(Int,N) for _=1:17]
const tour=Pair{Int,Int}[]
const L=zeros(Int,N)
function dfs(u,p,de)
	depth[u]=de
	parent[1][u]=p
	L[u]=length(tour)+1
	for (v,c,d)=G[u]
		if v!=p
			push!(tour,c=>d)
			dfs(v,u,de+1)
			push!(tour,c=>-d)
		end
	end
end
dfs(1,0,0)
const edge=[Int[] for _=1:N-1]
const edgesum=[Int[0] for _=1:N-1]
const edgecnt=[Int[0] for _=1:N-1]
function edgeinit()
	now=zeros(Int,N-1)
	cnt=zeros(Int,N-1)
	for i=1:length(tour)
		c,d=tour[i]
		cnt[c]+=d>0?1:-1
		now[c]+=d
		push!(edge[c],i)
		push!(edgesum[c],now[c])
		push!(edgecnt[c],cnt[c])
	end
end
edgeinit()
const cumsum=Int[0]
function cumsuminit()
	now=0
	for (c,d)=tour
		push!(cumsum,now+=d)
	end
end
cumsuminit()
function lca(u,v)
	if depth[u]>depth[v]
		u,v=v,u
	end
	for k=1:17
		if ((depth[v]-depth[u])>>(k-1))%2==1
			v=parent[k][v]
		end
	end
	if u==v
		return u
	end
	for k=17:-1:1
		if parent[k][u]!=parent[k][v]
			u=parent[k][u]
			v=parent[k][v]
		end
	end
	parent[1][u]
end
function lcainit()
	for k=2:17
		for i=1:N
			if parent[k-1][i]>0
				parent[k][i]=parent[k-1][parent[k-1][i]]
			else
				parent[k][i]=0
			end
		end
	end
end
lcainit()
function bsearch(A,x)
	L=0
	R=length(A)+1
	while R-L>1
		M=div(L+R,2)
		if A[M]>=x
			R=M
		else
			L=M
		end
	end
	R
end
function get(l,r,c)
	lid=bsearch(edge[c],l)
	rid=bsearch(edge[c],r)
	edgecnt[c][rid]-edgecnt[c][lid],edgesum[c][rid]-edgesum[c][lid]
end
function calc(u,v,x,y)
	flag=false
	if L[u]>L[v]
		u,v=v,u
		flag=true
	end
	ret=cumsum[L[v]]-cumsum[L[u]]
	cnt,sum=get(L[u],L[v],x)
	ret-=sum
	ret+=cnt*y
	if flag
		ret=-ret
	end
	ret
end
function query(u,v,x,y)
	pa=lca(u,v)
	calc(pa,u,x,y)+calc(pa,v,x,y)
end
function solve()
	for s=lines
		x,y,u,v=parseInt(s)
		println(query(u,v,x,y))
	end
end
solve()


Measured memory_bytes: 285404
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map(String::toInt)

    return when {
        a < 6 -> {
            println(0)
        }
        a < 13 -> {
            println(b / 2)
        }
        else -> {
            println(b)
        }
    }
}

Measured memory_bytes: 37648
/*input
5
1 1 2 2 3
2
1 2
*/
fn read_line() -> String {
    let mut return_ = format!("");
    std::io::stdin().read_line(&mut return_).ok();
    return_
}

fn main() {
    let n: u32 = read_line().trim().parse().expect("");
    let arr: Vec<u32> = read_line()
        .trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    let n_q: u32 = read_line().trim().parse().expect("");
    let arr_s: Vec<u32> = read_line()
        .trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    let mut total: u32 = 0;
    for i in 0..n_q {
        for j in 0..n {
            if arr[j as usize] == arr_s[i as usize] {
                total = total + 1;
                break;
            }
        }
    }
    println!("{}", total);
}



Measured memory_bytes: 5032
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;
 
string s;
 
int main() {
    ios::sync_with_stdio(false);
    cin>>s;
    bool flag=0;
    for(int i=0;i<3;++i){
        if(s[i]=='7'){
            flag=1;
            break;
        }
    }
    if(flag) printf("Yes\n");
    else printf("No\n");
 
 
 
 
 
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

vector<int> prime_vector(int n) {
    int m = (int)sqrt(n - 1);

    vector<bool> q(n);
    for (int i = 2; i <= m; i++) {
        if (q[i]) continue;
        for (int j = i * i; j < n; j += i) {
            q[j] = true;
        }
    }

    vector<int> p; p.reserve(n / log(n * 0.329));
    for (int i = 2; i < n; i++) {
        if (!q[i]) p.push_back(i);
    }
    return p;
}

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

    auto pv = prime_vector(100);
    
    int a[25] = {};
    for (int i = 1; i <= n; i++) {
        int t = i;
        for (int j = 0; j < 25; j++) {
            int p = pv[j];
            while (t % p == 0) t /= p, a[j]++;
        }
    }

    int b[75] = {};
    for (int j = 0; j < 25; j++) {
        for (int h = 0; h <= min(a[j], 74); h++) {
            b[h]++;
        }
    }

    int r = 0;
    r += b[74];
    r += b[24] * (b[2] - 1);
    r += b[14] * (b[4] - 1);
    if (b[4] >= 2) {
        r += b[4] * (b[4] - 1) / 2 * (b[2] - 2);
        //cout << t  << ' ' << b[2] << ' ' << b[4] << endl;
        //r += b[4] * (b[4] - 1) * (b[4] - 2) / 2;
        //r += (b[2] - b[4]) * b[4] * (b[4] - 1) / 2;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

struct mint {
    const int mod = 1e9 + 7;
    long long x;
    
    mint (long long x = 0) : x((x % mod + mod) % mod) {
        
    }
    
    mint& operator=(const long long a) {
        x = a % mod;
        return *this;
    }
    
    mint& operator=(const mint a) {
        x = a.x % mod;
        return *this;
    }
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    
    mint& operator-=(const mint a) {
        if ((x += (mod - a.x)) >= mod) x -= mod;
        return *this;
    }
    
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    
    mint inv() const {
        return pow(mod - 2);
    }
    
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    int sl = s.length();
    vector<vector<mint>> dp(sl, vector<mint>(2));
    rep(i, sl) {
        if (i == 0) {
            dp[i][0] = 2;
            dp[i][1] = 1;
        }
        else {
            if (s[i] == '1') {
                dp[i][0] = dp[i - 1][0] * 2;
                dp[i][1] = dp[i - 1][0] + dp[i - 1][1] * 3;
            }
            else {
                dp[i][0] = dp[i - 1][0];
                dp[i][1] = dp[i - 1][1] * 3;
            }
        }
    }
    cout << (dp[sl - 1][0] + dp[sl - 1][1]).x << endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    
    for(int i = 1; i <= n; i++){
        if(i % 3 == 0){
            cout << " " << i;
        }else{
            int x = i;
            while(x > 0){
                if(x % 10 == 3){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }
        }
    }
    cout << endl;
}



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

int main() {
  int N, K; cin >> N >> K;
  vector<vector<long long>> dp(N+1, vector<long long>(N+1, 0));
  long long MOD = 1000000007;
  for (int i = 0; i <= N; i++) dp.at(i).at(0) = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= i; j++) {
      dp.at(i).at(j) = (dp.at(i-1).at(j-1) + dp.at(i-1).at(j)) % MOD;
    }
  }
  for (int i = 1; i <= K; i++) {
    if (N-K+1 < i) {
      cout << 0 << endl;
      continue;
    }
    long long ans = (dp.at(N-K+1).at(i) * dp.at(K-1).at(i-1)) % MOD;
    cout << ans << endl;
  }
}

Measured memory_bytes: 31616
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(A));

        sc.close();
    }

    static int solve(int[] A) {
        List<Integer> lastValues = new ArrayList<>();
        for (int Ai : A) {
            int index = findIndex(lastValues, Ai);
            if (index == lastValues.size()) {
                lastValues.add(Ai);
            } else {
                lastValues.set(index, Ai);
            }
        }

        return lastValues.size();
    }

    static int findIndex(List<Integer> lastValues, int x) {
        int result = lastValues.size();
        int lower = 0;
        int upper = lastValues.size() - 1;
        while (lower <= upper) {
            int middle = (lower + upper) / 2;
            if (lastValues.get(middle) < x) {
                result = middle;
                upper = middle - 1;
            } else {
                lower = middle + 1;
            }
        }

        return result;
    }
}

Measured memory_bytes: 58956
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(N);
  rep(i,M){
    int a,b;
    cin>>a>>b;
    a--,b--;
    A[a]++;
    A[b]++;
  }
  rep(i,N)
    cout<<A[i]<<endl;
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

typedef pair<double, double> pd;
typedef vector<pd> vpd;


#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

ll D;
vll c(26);
vvll s;
vll t;
vll last(26, 0);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  IN(D);
  REP(i,26){
    IN(c[i]);
  }
  s.resize(D, vll(26));
  REP(i,D){
    REP(j,26){
      IN(s[i][j]);
    }
  }
  ll ans = 0;
  t.resize(D);
  REP(i,D){
    IN(t[i]);
    t[i]--;


    ans += s[i][t[i]];

    last[t[i]] = i+1;
    ll tmp = 0;
    REP(j,26){
      tmp += c[j]*(i+1-last[j]);
    }

    ans -= tmp;

    OUT(ans);
  }



  return 0;
}

Measured memory_bytes: 3752
N,K,Q=map(int,input().split())
Ans=[]
for i in range(N):
    Ans.append(0)
for i in range(Q):
    Ans[int(input())-1]+=1
for i in range(N):
    if abs(Ans[i]) <= Q-K:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 4620
n = int(input())
c_list = list(input())
start = 0
end = n
ans = 0

while 1:
    for i in range(start, n):
        start = i
        if c_list[i] == "W":
            break
    for i in reversed(range(end)):
        end = i
        if c_list[i] == "R":
            break
    if start >= end:
        break

    c_list[start], c_list[end] = c_list[end], c_list[start]
    start += 1
    ans += 1

print(ans)


Measured memory_bytes: 10724
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    a=LI()
    ALL=0
    for i in range(N):
        ALL=ALL^a[i]
        
    ans=[0]*N
    for i in range(N):
        ans[i]=ALL^a[i]
        
    print(' '.join(map(str, ans)))

main()


Measured memory_bytes: 117152
#include<stdio.h>
int main()
{
    int n,i,sum=0,fn;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum=sum+a[i];
    }
    fn=sum-n;
    printf("%d\n",fn);
    return 0;
}


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

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF = 1LL << 60;


int main(){

    int d,n;
    cin >> d >> n;
    if(d==0){
      if(n!=100){
        cout << n << endl;
      }else{
        cout << 101 << endl;
      }
    }
    if(d==1){
      if(n!=100){
        cout << n*100 << endl;
      }else{
        cout << 10100 << endl;
      }
    }
    if(d==2){
      if(n!=100){
        cout << n*10000 << endl;
      }else{
        cout << 1010000 << endl; 
      }
    }
}


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

int main(void) {
  int n, i;
  int* a;
  scanf("%d", &n);
  a = (int*)malloc(n*sizeof(int));
  for(i=0; i<n; i++) {
    scanf("%d", &a[i]);
  }
  for(i=0; i<n; i++) {
    if(a[i] % 2 == 0) {
      if(!(a[i] % 3 == 0 || a[i] % 5 == 0)) {
        printf("DENIED\n");
        return 0;
      }
    }
  }
  printf("APPROVED\n");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N;
  cin >> N;

  vector<int> A(N),B(N),C(N-1);
  for(int i = 0;i < N;i++) {
    cin >> A.at(i);
  }

  int ans = 0;
  for(int i = 0;i < N;i++) {
    cin >> B.at(i);
    ans += B.at(i);
  }

  for(int i = 0;i < N-1;i++) {
    cin >> C.at(i);
  }

  for(int i = 0;i < N-1;i++) {
    if(A.at(i+1) - A.at(i) == 1) ans += C.at(A.at(i)-1);
  }

  cout << ans << endl;

  

}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <array>
#include <chrono>
#include <numeric>
#include <algorithm>

using namespace std;

int main() {
	long long H, N;

	cin >> H >> N;

	vector<long long> A(N);
	vector<long long> B(N);

	for(int i=0;i<N;i++){
		cin >> A[i] >> B[i];
	}

	vector<long long> min_mp(H+1);

	for(int h=1;h<=H;h++){
		min_mp[h] = min_mp[h-1] + B[0];
		for(int i=0;i<N;i++){
			long long mp;
			if( h <= A[i] ){
				mp = B[i];
			}
			else{
				mp = B[i] + min_mp[h-A[i]];
			}
			if(mp < min_mp[h]){
				min_mp[h] = mp;
			}
		}
	}

	cout << min_mp[H] << endl;

	return 0;
}



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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)
#define loop1(i,n)  for(ll i=1; i<=n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " = " << x << endl
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define F first
#define S second


#define inf (int)1e9
#define infll 1e18
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


int dirx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int diry[] = { -1, 0, 1, -1, 1, -1, 0, 1 };



//===========================DEBUG======================//
#define XOX 1
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

//================================================================//



//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;
ll a[200];

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

    ll n,k; cin>>n>>k;
    
    loop(j,k){
    	int d,ele; cin>>d;
    	loop(i,d){
    		cin>>ele;
    		a[ele]++;
    	}
    }
    int cnt=0;
    loop1(i,n) if(!a[i]) cnt++;

    pt(cnt);
}


/*



*/





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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    if (m[tmp] == 0) {
      m[tmp]++;
    } else {
      m[tmp]--;
    }
  }
  int cnt = 0;
  for (auto v : m) {
    if (v.second == 1) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 5376
"王様の視察"
while True:
    N = int(input())
    if N == 0:
        break
    K = list(map(int, input().split()))
    S = str(input())

    ans = ""
    station = list("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
    station_position = {}
    search_station = {}
    # 双方向の辞書を作成する
    for i, s in enumerate(station, start=1):
        station_position.setdefault(i)
        station_position[i] = s  # keyが数字で、バリューが文字
        search_station[s] = i  # keyが文字で、バリューが数字
    i = 0
    for s in S:
        encryption = search_station[s]  # 数字
        encryption -= K[i]
        if encryption <= 0:
            encryption += 52
        ans += station_position[encryption]
        i += 1
        if i == len(K):
            i = 0
    print(ans)



Measured memory_bytes: 5616