akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

int main() {
   string N;
   cin >> N;
   if(N[0] == '9' || N[1] == '9') cout << "Yes" << endl;
   else cout << "No" << endl;
}

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

int reverse(int n) {
  int reverse = 0;
  while (n > 0) {
    reverse = 10 * reverse + (n % 10);
    n /= 10;
  }
  return reverse;
}

bool isKaibunsu(int n) {
  if (n == reverse(n)) return true;
  else return false;
}

int main() {
  int a, b, cnt = 0;
  cin >> a >> b;
  for (int i = a; i <= b; i++) if (isKaibunsu(i)) cnt++;
  cout << cnt << endl;
}

Measured memory_bytes: 256
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
maxi=a[1]-a[0]
mini=a[0]
for j in range(1,n):
    if a[j]-mini>maxi:
        maxi=a[j]-mini
    if a[j]<mini:
        mini=a[j]
print(maxi)


Measured memory_bytes: 13588
import java.util.Scanner;

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

		int n = scanner.nextInt();

		int t1 = 0;
		int x1 = 0;
		int y1 = 0;

		boolean canArrive = true;
		for (int i = 0; i < n; i++) {
			int t2 = scanner.nextInt();
			int x2 = scanner.nextInt();
			int y2 = scanner.nextInt();

			int time = t2 - t1;
			int distance = Math.abs(x2 + y2 - x1 - y1);
			if (distance > time || (distance + time) % 2 == 1) {
				canArrive = false;
				break;
			}

			t1 = t2;
			x1 = x2;
			y1 = y2;
		}

		if (canArrive) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		scanner.close();
	}
}

Measured memory_bytes: 84340
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define IOS ios::sync_with_stdio(false); cin.tie(NULL);
#ifndef LOCAL
#define dbg(...) ;
#define endl '\n'
#endif

const int inf = 1e15;
const int MOD = 1e9 + 7;
const int N = 2e5 + 5;



signed main(){
    IOS;
    int a, b;
    cin >> a >> b;
    if (b >= a) cout << "unsafe";
    else cout << "safe";
    return 0;
}

Measured memory_bytes: 3640
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl

using namespace std;

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

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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

//累乗だってさ
ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll combination(ll n,ll r){
    ll sum=1;
    rrep(i,min(r,n-r)) (sum*=(n-i+1))%=mod;
    return sum;
}

//逆元だってさ
ll modinv(ll a,ll mod1) {
    return modpow(a, mod1 - 2, mod1);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,a,b,sum=0;
    cin>>n>>a>>b;
    sum = modpow(2,n,mod)-1;
    ll A=factorial(min(a,n-a)),B=factorial(min(b,n-b));
    sum -=  combination(n,a) * modinv(A,mod) %mod;
    sum += mod;
    sum -=  combination(n,b) * modinv(B,mod) %mod;
    sum += mod;
    
    
    cout<<sum%mod<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
     
int main() {
    int sum = 0;
    for( int i = 0; i < 4; i++ ) {
    	int j;
    	cin >> j;
    	sum += j;
    }
    cout << sum / 60 << endl;
    cout << sum % 60 << endl;
     
    return 0;
}

Measured memory_bytes: 1160
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
)

// const (
// 	initialBufSize = 10000
// 	maxBufSize     = 100000000
// )
//
// var sc *bufio.Scanner = func() *bufio.Scanner {
// 	sc := bufio.NewScanner(os.Stdin)
// 	buf := make([]byte, initialBufSize)
// 	sc.Buffer(buf, maxBufSize)
// 	return sc
// }()

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func init() {
	sc.Buffer(buff, 100000000)
	log.SetFlags(log.Lshortfile)
}

func main() {
	input := nextString()
	remSumArray := make([]int, 2019)
	remSumArray[0] = 1
	var num int
	digit := 1
	for i := len(input) - 1; i >= 0; i-- {
		num += int(input[i]-48) * digit
		digit *= 10
		digit %= 2019
		remSumArray[num%2019]++
	}
	var result int
	for _, num := range remSumArray {
		result += num * (num - 1) / 2
	}
	fmt.Println(result)
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 2508
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  vector<char> vec;
  vec.push_back(s[0]);
  char c = s[0];
  for (int i = 1; i < s.size(); i++) {
    if (c != s[i]) {
      vec.push_back(s[i]);
      c = (c == 'W' ? 'B' : 'W');
    }
  }
  cout << vec.size() - 1 << endl;
  return 0;
}


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

using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;
using str = string;
using bl = bool;
using ch = char;

template<class T> using v = vector<T>;
template<class T> using uset = unordered_set<T>;
template<class T1, class T2> using umap = unordered_map<T1, T2>;

template<class T> void pd(T x)
{
    cout << x << " ";
}
template<class T> void pl(T x)
{
    cout << x << endl;
}

#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define sz(x) ((int)(x).size())
#define ph push_back
#define pp pop_back
#define mp make_pair
#define rep(i, a) for(int i = 0; i < (int)a; ++i)
#define repd(i, a) for(int i = (int)a; i >= 0; --i)
#define REP(i, a, b) for(int i = a; i < (int)b; ++i)
#define REPD(i, a, b) for(int i = (int)a; i >= b; --i)
#define fore(i, a) for(auto& i : a)
#define FORE(i, a) for(auto i : a)

// -----



int main()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> h(n);
    for(auto& i : h) cin >> i;
    vector<vector<ll>> p(n, vector<ll>());
    rep(i, m)
    {
        ll a, b;
        cin >> a >> b;
        p[a - 1].ph(b - 1);
        p[b - 1].ph(a - 1);
    }
    ll ans = 0;
    rep(i, n)
    {
        bool fl = true;
        for(auto x : p[i])
        {
            if(!fl) break;
            fl = h[i] > h[x];
        }
        if(fl) ++ans;
    }
    pl(ans);
}

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

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

    int N, D;
    cin >> N >> D;
    vector<int> X(N), Y(N);
    for(int i = 0; i < N; ++i)  cin >> X[i] >> Y[i];

    vector<vector<int>> graph(N * 2), rev(N * 2);
    for(int i = 0; i < N; ++i){
        for(int j = 0; j < i; ++j){
            if(abs(X[i] - X[j]) < D){
                graph[i * 2 + 1].emplace_back(j * 2);
                graph[j * 2 + 1].emplace_back(i * 2);
                rev[i * 2].emplace_back(j * 2 + 1);
                rev[j * 2].emplace_back(i * 2 + 1);
            }
            if(abs(X[i] - Y[j]) < D){
                graph[i * 2 + 1].emplace_back(j * 2 + 1);
                graph[j * 2].emplace_back(i * 2);
                rev[i * 2].emplace_back(j * 2);
                rev[j * 2 + 1].emplace_back(i * 2 + 1);
            }
            if(abs(Y[i] - X[j]) < D){
                graph[i * 2].emplace_back(j * 2);
                graph[j * 2 + 1].emplace_back(i * 2 + 1);
                rev[i * 2 + 1].emplace_back(j * 2 + 1);
                rev[j * 2].emplace_back(i * 2);
            }
            if(abs(Y[i] - Y[j]) < D){
                graph[i * 2].emplace_back(j * 2 + 1);
                graph[j * 2].emplace_back(i * 2 + 1);
                rev[i * 2 + 1].emplace_back(j * 2);
                rev[j * 2 + 1].emplace_back(i * 2);
            }
        }
    }

    vector<int> vs;
    vector<bool> used(N * 2, false);
    auto dfs = [&](auto&& self, int cur) -> void {
        used[cur] = true;
        for(int nxt : graph[cur]){
            if(!used[nxt])  self(self, nxt);
        }
        vs.emplace_back(cur);
    };
    for(int v = 0; v < N * 2; ++v){
        if(!used[v])    dfs(dfs, v);
    }
    reverse(vs.begin(), vs.end());

    vector<int> scc_id(N * 2, -1);
    int K = 0;
    auto rdfs = [&](auto&& self, int cur) -> void {
        scc_id[cur] = K;
        for(int nxt : rev[cur]){
            if(scc_id[nxt] == -1)   self(self, nxt);
        }
    };
    for(int v : vs){
        if(scc_id[v] == -1){
            rdfs(rdfs, v);
            ++K;
        }
    }

    vector<bool> ans(N);
    for(int i = 0; i < N; ++i){
        if(scc_id[i * 2] == scc_id[i * 2 + 1]){
            cout << "No\n";
            return 0;
        }
        ans[i] = scc_id[i * 2] < scc_id[i * 2 + 1];
    }

    cout << "Yes\n";
    for(int i = 0; i < N; ++i)  cout << ((ans[i] ? X[i] : Y[i])) << '\n';
}

Measured memory_bytes: 3812
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

typedef long long ll;
using namespace std;
#define mod 1000000007

int main(){
    int n;cin >> n;
    vector<int>a(n),b(n,0);
    int m=0,sum=0;
    
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int cnt=0;
    for(int i=0;i<n;i++){
        if(a[i]==0)cnt++;
    }
    if(cnt==n){
        cout << 0 << endl;
        return 0;
    }
    
    
    
    for(int i=n-1;i>=0;i--){
        sum=0;
        if(a[i]==1){
            int x=1;
            while((i+1)*x-1<n){
                sum+=b[(i+1)*x-1];
                x++;
            }
            if(sum%2!=a[i]){
                b[i]=1;
                m++;
            }
        }
        
        else{
            int x=1;
            while((i+1)*x-1<n){
                sum+=b[(i+1)*x-1];
                x++;
            }
            if(sum%2!=a[i]){
                b[i]=1;
                m++;
            }
        }
    }
    if(m>0){
        cout << m << endl;
        for(int i=0;i<b.size();i++){
            if(b[i]==1){
                cout << i+1 << " ";
            }
        }
        cout << endl;
    }
    else cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, n) for (ll i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _per(i, n) peri(i, 0, n)
#define peri(i, a, n) for (ll i = (n) - 1; i >= (a); --i)
#define per(...) _overload3(__VA_ARGS__, peri, _per)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void chmax(T& a, const T& b) {if (a < b) a = b;}
template<typename T> inline void chmin(T& a, const T& b) {if (a > b) a = b;}
template<typename T> inline void print(const T& x) {cout << x << "\n";}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) {is >> p.fi >> p.se; return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) {os << p.fi << " " << p.se; return os;}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {each(in, v) is >> in; return is;}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {rep(i, sz(v)) {os << v[i] << (i + 1 != sz(v) ? " " : "");} return os;}
struct Init {Init() {ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(10);}} init;

int main() {
    ll n, m; cin >> n >> m;
    vi p(m), y(m);
    rep(i, m) {
        cin >> p[i] >> y[i];
        --p[i];
    }
    vvi vals(n);
    rep(i, m) vals[p[i]].pb(y[i]);
    rep(i, n) sort(all(vals[i]));
    rep(i, m) {
        ll v = p[i];
        printf("%06d", v + 1);
        ll id = lower_bound(all(vals[v]), y[i]) - vals[v].begin();
        printf("%06d\n", id + 1);
    }
}

Measured memory_bytes: 8576
import heapq
n,m = map(int,input().split())
q = [[] for i in range(m)]
for i in range(n):
  a,b = map(int,input().split())
  a -= 1
  if a < m:
    heapq.heappush(q[a],-b)
a = 0
cur = []
for i in range(m):
  for j in q[i]:
    heapq.heappush(cur,j)
  if cur:
    a += heapq.heappop(cur)
print(-a)

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

int main()
{
  int n;
  cin >> n;
  
  int v[n],c[n];
  int total = 0;
  for(int i = 0; i < n; i++)
    cin >> v[i];
  
  for(int i = 0; i < n; i++)
  {
    cin >> c[i];
    if(v[i] - c[i] >= 0)
      total += v[i] - c[i];
  }
 
  
  cout << total;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;

int main(int argc, char* argv[]) {
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(b, n * a) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
if(s=="SUN"){
    cout<<"7"<<endl;
}
if(s=="MON"){
    cout<<"6"<<endl;
}
if(s=="TUE"){
    cout<<"5"<<endl;
}
if(s=="WED"){
    cout<<"4"<<endl;
}
if(s=="THU"){
    cout<<"3"<<endl;
}
if(s=="FRI"){
    cout<<"2"<<endl;
}
if(s=="SAT"){
    cout<<'1'<<endl;
}
return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	fsc := NewFastScanner()
	N, A, B := fsc.NextInt(), fsc.NextInt(), fsc.NextInt()
	res := IntMin(A*N, B)
	fmt.Println(res)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>

#include <numeric>

#include <map>

#include <deque>

#include <cassert>

#include <memory>

using namespace std;

typedef unsigned long long LL;

char s[222];

int main() {

  scanf("%s", s);
  for (int i = 0; s[i]; ++i) {
      if (s[i] == '7') {
          cout << "Yes";
          return 0;
      }
  }
  cout << "No";
    

}

Measured memory_bytes: 3760
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N;
	cin >> N;
	long long L = 1, R = 26;
	for (int i = 1; ; i++) {
		if (L <= N && N <= R) {
			N -= L;
			string S = "";
			for (int j = 0; j < i; j++) {
				S += 'a' + N % 26;
				N /= 26;
			}
			reverse(S.begin(), S.end());
			cout << S << endl;
			return 0;
		}
		L *= 26;
		L++;
		R++;
		R *= 26;
	}
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int d;
 if(a > b){
     d= a;
     a = b;
     b = d;
 }
  if(b > c){
      d=b;
      b=c;
      c=d;
  }
 if(a > b){
     d=a;
     a=b;
     b=d;
 }
    System.out.println(a+" "+b+" "+c);         
    }
}



Measured memory_bytes: 26152
#input
N, K, Q = map(int, input().split())
A = [0] * Q
for i in range(Q):
    A[i] = int(input())

#output
from collections import Counter
point = [(K-Q)] * N
C = Counter(A)

for i, j in C.items():
    point[(i-1)] += j

for i in range(N):
    if point[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 13932
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))

h,w = iim()
l = []
for _ in range(h):
    l.append(list(input()))

flag = True
for i in range(h):
    for j in range(w):
        if l[i][j] == '#' and (i != h-1 or j != w-1):
            if i < h-1 and j < w-1:
                if l[i][j+1] == l[i+1][j]:
                    flag = False
            elif i == h-1:
                if l[i][j+1] != '#':
                    flag = False
            elif j == w-1:
                if l[i+1][j] != '#':
                    flag = False

for i in range(h):
    for j in range(w):
        if l[i][j] == '#' and i*j != 0:
            if i > 0 and j > 0:
                if l[i][j-1] == l[i-1][j]:
                    flag = False
            elif i == 0:
                if l[i][j-1] != '#':
                    flag = False
            elif j == 0:
                if l[i-1][j] != '#':
                    flag = False


print('Possible' if flag else 'Impossible')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
using P=pair<int,int>;
ll c(ll n){
    return n*(n-1)/2;
}
int main() {
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
        a[i]--;
    }
    vector<ll> cnt(n);
    rep(i,n){
        cnt[a[i]]++;
    }
    ll base=0;
    for(int i=0;i<n;i++){
        base+=cnt[i]*(cnt[i]-1)/2;
    }
    for(int i=0;i<n;i++){
        ll result=base;
        result-=cnt[a[i]]*(cnt[a[i]]-1)/2;
        result+=(cnt[a[i]]-1)*(cnt[a[i]]-2)/2;
        cout<<result<<endl;
    }
}

Measured memory_bytes: 5760
# C
N = int(input())
x_list = []
for _ in range(N):
    x_list.append(int(input()))

res = sum(x_list)

if res % 10 == 0:
    x_non10 = [x for x in x_list if x % 10 != 0]
    if len(x_non10) > 0:
        res -= min(x_non10)
    else:
        res = 0

print(res)

Measured memory_bytes: 3060
MAX = 1000
VMAX = 10000


def main():
    n = int(input())
    
    a_s = list(map(int, input().split(' ')))
    minimum = min(a_s)

    ans = 0

    t_s = [0] * (VMAX+1)
    b_s = [a for a in a_s]
    v_s = [False for _ in range(n)]
    b_s = sorted(b_s)

    for i in range(n):
        t_s[b_s[i]] = i

    for i in range(n):
        if v_s[i]:
            continue
        cur = i
        S = 0
        m = VMAX
        a_n = 0

        while True:
            v_s[cur] = True
            a_n += 1
            v = a_s[cur]
            m = min(m, v)
            S += v
            cur = t_s[v]
            if v_s[cur]:
                break
        ans += min(S + (a_n-2)*m, m+S+(a_n+1)*minimum)
    
    print(ans)


if __name__ == '__main__':
    main()



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

const int INF = 1e9+7;

typedef tuple<int, int, int> iii;

int dist[105][105];

char grid[105][105];

const int dx[] = {0,1};
const int dy[] = {1,0};

int main(){
    int H, W;
    scanf("%d%d", &H, &W);

    for(int i = 0; i < H; i ++){
        scanf(" %s", grid[i]);
    }

    for(int i = 0; i < H; i ++){
        for(int j = 0; j < W; j ++){
            dist[i][j] = INF;
        }
    }
    dist[0][0] = grid[0][0] == '#';
    priority_queue<iii, vector<iii>, greater<iii> > pq;
    pq.push(iii(0, 0, 0));
    while(!pq.empty()){
        iii temp = pq.top(); pq.pop();
        int d, x, y;
        tie(d, x, y) = temp;

        if(d > dist[x][y]){continue;}

        for(int k = 0; k < 2; k ++){
            int nx = x + dx[k];
            int ny = y + dy[k];
            if(nx >= 0 && nx < H && ny >= 0 && ny < W){
                int w = grid[x][y] == '.' && grid[nx][ny] == '#';
                if(dist[nx][ny] > dist[x][y] + w){
                    dist[nx][ny] = dist[x][y] + w;
                    pq.push(iii(dist[nx][ny], nx, ny));
                }
            }
        }
    }

    printf("%d", dist[H-1][W-1]);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{
    string s[3];
    queue<char>q1,q2,q3;
    for(int i=0;i<3;i++){
        cin>>s[i];
    }
    for(int i=0;i<s[0].size();i++)
    {
        q1.push(s[0][i]);
    }
    for(int i=0;i<s[1].size();i++)
    {
        q2.push(s[1][i]);
    }
    for(int i=0;i<s[2].size();i++)
    {
        q3.push(s[2][i]);
    }

 int ans=-1,x=0;
 while(true)
 {


     if(x==0)
     {
          if(x==0&&q1.empty())
          {
              ans=0;
              break;
          }
          char ch=q1.front();
          q1.pop();
          if(ch=='a')x=0;
          else if(ch=='b')x=1;
          else x=2;

     }
      if(x==1)
     {
          if(x==1&&q2.empty())
          {
              ans=1;
              break;
          }
         char ch=q2.front();
          q2.pop();
          if(ch=='a')x=0;
          else if(ch=='b')x=1;
          else x=2;

     }
     if(x==2)
      {
          if(x==2&&q3.empty())
          {
              ans=2;
              break;
          }
          char ch=q3.front();
          q3.pop();
          if(ch=='a')x=0;
          else if(ch=='b')x=1;
          else x=2;
      }
 }



        if(ans==0)cout<<"A"<<endl;
    else if(ans==1)cout<<"B"<<endl;
    else cout<<"C"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int>v(n);
  vector<int>c(n);
  int ans =0;
  for(int i = 0;i < n;i++) cin >> v[i];
  for(int i = 0;i < n;i++)
  {
    cin >> c[i];
    if(c[i] < v[i]) ans += v[i] - c[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
	
		long Inf = (long) 1e18;
		Func<long, long, long> A = (x, y) => y >= x ? y - x : Inf;
		
		var L = new List<long>();
		
		// X X Y Y;
		L.Add(0 + A(X,Y) + 0);
		// X -X Y Y;
		L.Add(1 + A(-X,Y) + 0);
		// X X -Y Y;
		L.Add(0 + A(X,-Y) + 1);
		// X -X -Y Y;
		L.Add(1 + A(-X,-Y) + 1);
		// X Y X Y;
		L.Add(A(X,Y) + A(Y,X) + A(X,Y));
		// X -Y X Y;
		L.Add(A(X,-Y) + A(-Y,X) + A(X,Y));
		// X Y -X Y;
		L.Add(A(X,Y) + A(Y,-X) + A(-X,Y));
		// X -Y -X Y;
		L.Add(A(X,-Y) + A(-Y,-X) + A(-X,Y));
		
		Console.WriteLine(L.Min());
		
		
		
		
	}
	long X, Y;
	public Sol(){
		var d = rla();
		X = d[0]; Y = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

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

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

unsigned GetDigit(unsigned num) { return to_string(num).length(); }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

ll nCr(int n, int r)
{
    if (n == r or n == 0)
        return 1;
    if (n < r)
        return 0;
    if (r == 1)
        return n;
    return nCr(n - 1, r - 1) + nCr(n - 1, r);
}

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll N,K; cin >> N >> K;
    vector<int> A(N);
    REP(i,N) cin >> A[i];
    REP(i,N) A[i]--;

    bool flag[N]={false};
    vector<int> res;

    int i=0, cknum;
    while(1){
        if(!flag[A[i]]){
            flag[A[i]]=true;
            res.push_back(A[i]);
            i=A[i];
        }else{
            res.push_back(A[i]);
            cknum=A[i];
            break;
        }
    }

    //REP(i,res.size()) cout << "res[i]= " << res[i] << endl;

    bool flag2=false;
    int begin,roopcnt;
    REP(i,res.size()){
        if(res[i]==cknum and !flag2){
            flag2 = true;
            begin = i;
        }else if(res[i]==cknum and flag2){
            roopcnt = i-begin;
        }
    }

    //cout << "roopcnt= "  << roopcnt << endl;

    int remain = res.size() - roopcnt;
    //cout << remain << endl;

    //REP(i,N) cout << A[i] << endl;

    if(remain >= K){
        if(K==1){
            cout << 1 << endl;
            return 0;
        }else{
            cout << res[K-1] + 1 << endl;
            return 0;
        }
    }else{
        int remcnt = (K-remain) % roopcnt;
        //cout << remcnt << endl;
        cout << res[remain + remcnt - 1] + 1 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 5232
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


class FenwickTree{
public:
    vector<int> bit;
    int n;

    FenwickTree() = default;
    FenwickTree(int _n) : n(_n){
        bit.assign(n, 0);
    } 

    FenwickTree(vector<int>& vec) : FenwickTree(vec.size()) {
        for(int i = 0; i<vec.size(); ++i)
            update(i, vec[i]);
    }

    ll sum(int r){
        int res = 0;
        for(; r>=0; r = (r & (r+1)) - 1)
            res += bit[r];

        return res;
    }

    ll sum(int l, int r)
    {
        return sum(r) - sum(l-1);
    }

    void update(int ind, int delta){
        for(; ind<n; ind = ind | (ind+1))
            bit[ind] += delta;
    }
};

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int q;
    cin>>q;

    vector<vector<int>> vec(26, vector<int>(n));
    for(int i = 0; i<n; ++i)
    {
        vec[s[i]-'a'][i] = 1;
    }

    vector<FenwickTree> ftree(26);
    for(int i = 0; i<26; ++i)
    {
        ftree[i] = FenwickTree(vec[i]);
    }

    while(q--)
    {
        int t, l;
        cin>>t>>l;
        if(t==1)
        {
            char r;
            cin>>r;
            ftree[r-'a'].update(l-1, 1);
            ftree[s[l-1]-'a'].update(l-1, -1);
            s[l-1] = char(r);
        }
        else
        {
            int r;
            cin>>r;
            int ans = 0;
            for(int i = 0; i<26; ++i)
            {
                ans += ftree[i].sum(l-1, r-1)>0;
            }
            cout<<ans<<endl;
        }
    }
}


Measured memory_bytes: 102496
cs = [list(map(int, input().split())) for _ in range(3)]

r_sum = [sum(l) for l in cs]
total = sum(r_sum)

ok = True
for i in range(3):
    diffs = [cs[i][j] - cs[(i + 1) % 3][j] for j in range(3)]
    d0 = diffs[0]
    for j in range(1, 3):
        if diffs[j] != d0:
            ok = False
            break
    if not ok:
        break
if ok:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
typedef long long                   ll;
typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;
#define ts(x)                       to_string(x)
#define ti(x)                       stoi(x)
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define tab                         '\t'
#define sep                         ' '
#define mine(v)                     *min_element(all(v))
#define maxe(v)                     *max_element(all(v))
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r+" , stdin) ; freopen("out.txt" , "w+" , stdout);
#define SIZE(x)                     (int)x.size()
#define endl                        "\n"
inline ll input(){ll n; cin >> n ; return n;}

const int MAXN = 1e6 + 10;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
const ll INF = 8e18;

ll pw(ll a , ll b)  { return (!b ? 1 : (b & 1 ? (a * pw(a * a % MOD, b / 2)) % MOD : pw(a * a % MOD, b / 2))); }

ll dp[MAXN];

int main(){
    fast_io;
    //cout << fixed << setprecision(15);
    //scanf("%d %d %f %lld %s %c", &x);
    //printf("%d %d %f %lld %s %c", x);
    int n, m, a, b, q;
    cin >> n >> m;
    for(int i = 0; i <= (1 << n); i++){
        dp[i] = 1e18;
    }
    dp[0] = 0;
    for(int i = 0; i < m; i++){
        int cu = 0;
        cin >> a >> b;
        for(int i = 0; i < b; i++){
            cin >> q;
            cu = cu | (1 << (q - 1));
        }
        for(int j = 0; j <= (1 << n); j++){
            dp[j | cu] = min(dp[j | cu], dp[j] + a);
        }
    }
    if(dp[(1 << n) - 1] == 1e18){
        return cout << -1, 0;
    }
    cout << dp[(1 << n) - 1];
    return 0;
}




Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var a int
	var b int

	fmt.Scan(&a)
	fmt.Scan(&b)

	if (a+b)%2 == 0 {
		fmt.Println((a + b) / 2)
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 1768
S = input()
reS = S[::-1]
if S != reS:
    print("No")
    exit()
N = len(S)
minS = S[:(N - 1) // 2]
minreS = minS[::-1]
maxS = S[(N + 2) // 2:]
maxreS = maxS[::-1]
if minS == minreS and maxS == maxreS:
    print("Yes")

else:
    print("No")

Measured memory_bytes: 3064
program DISCO2020yC
integer::H,W,K
integer,allocatable::ans(:,:)
character(300)reader
integer ichigonumber
read*,H,W,K
allocate(ans(H,W))
ans=-1
ichigonumber=1
do i=1,H
    read*,reader
    do j=1,W
        if(reader(j:j)=="#")then
            ans(i,j)=ichigonumber
            ichigonumber=ichigonumber+1
        endif
    end do
end do
do i=1,H
    do j=1,W
        if(ans(i,j)==-1)then
            if(j==1)cycle
            if(ans(i,j-1)>0)then
                ans(i,j)=ans(i,j-1)
            endif
        endif
    end do
    do j=W,1,-1
        if(ans(i,j)==-1)then
            if(j==W)cycle
            if(ans(i,j+1)>0)then
                ans(i,j)=ans(i,j+1)
            endif
        endif
    end do
end do
do i=1,H
    if(ans(i,1)<0)then
        if(i==1)cycle
        if(ans(i-1,1)>0)then
            ans(i,:)=ans(i-1,:)
        endif
    endif
end do
do i=H,1,-1
    if(ans(i,1)<0)then
        if(i==H)cycle
        if(ans(i+1,1)>0)then
            ans(i,:)=ans(i+1,:)
        endif
    endif
end do
do i=1,H
    write(*,"(i0)",advance="no") ans(i,1)
    do j=2,W
        write(*,"(A,i0)",advance="no")" ",ans(i,j)
    end do
    write(*,*)
end do
end

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

int main() {
	int X, Y;
	cin >> X >> Y;
	cout << X + (Y >> 1);
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

やるだけ
*/


Measured memory_bytes: 256
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){ 
    string s; int n,on=0,tw=0,th=0; 
    cin >> s >> n ; 
    string two=s+s,one=s,three=s+s+s;
    for (int i=0;i+1<sz(two);i++) {
        if (two[i]==two[i+1]){
            tw++;
            i++;
        }
    }
    for (int i=0;i+1<sz(one);i++) {
        if (one[i]==one[i+1]){
            on++;
            i++;
        }
    }for (int i=0;i+1<sz(three);i++) {
        if (three[i]==three[i+1]){
            th++;
            i++;
        }
    }
    if (sz(s)==1)
        cout << n/2 << endl;
    else if (on+tw==th)
        cout << (n/2*tw+(n&1)*on) << endl;
    else 
        cout << (tw-on)*(n-1)+on << endl;
} 

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0; 
}


/*

aaa

*/

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

using namespace std;

int main(){
  long long A, B, N;
  cin >> A >> B >> N;
  
  long long x = min(N, B - 1);
  cout << (A * (x % B) - (A * x) % B) / B << endl;
  
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
string f(char s){
	if(s=='W')return "S";
	return "W";
}
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	string out;
	string q[4]={"SS","WW","SW","WS"};
	rep(w,4){
		out=q[w];
		loop(i,1,n-1){
			if(out[i]=='S'){
				if(s[i]=='o')out+=out[i-1];
				else out+=f(out[i-1]);
			}else{
				if(s[i]=='o')out+=f(out[i-1]);
				else out+=out[i-1];
			}
		}
		bool h=true;
		if(out[n-1]=='S'){
			if(s[n-1]=='o'&&out[n-2]!=out[0]||s[n-1]=='x'&&out[n-2]==out[0])h=false;
		}else{
			if(s[n-1]=='o'&&out[n-2]==out[0]||s[n-1]=='x'&&out[n-2]!=out[0])h=false;
		}
		if(out[0]=='S'){
			if(s[0]=='o'&&out[n-1]!=out[1]||s[0]=='x'&&out[n-1]==out[1])h=false;
		}else{
			if(s[0]=='o'&&out[n-1]==out[1]||s[0]=='x'&&out[n-1]!=out[1])h=false;
		}
		if(h){
			cout<<out<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
}











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

using uint = unsigned int;
using ull = unsigned long long;

template <uint MOD>
struct modnum {
	using num = modnum;
	uint v;
	modnum(uint _v = 0) : v(_v) {}
	num& operator += (const num& r) {
		if ((v += r.v) >= MOD) v -= MOD;
		return *this;
	}
	num& operator -= (const num& r) {
		if ((r += MOD - r.v) >= MOD) r -= MOD;
		return *this;
	}
	num& operator *= (const num& r) {
		v = ull(v) * r.v % MOD;
		return *this;
	}
	num operator + (const num& r) const { return num(*this) += r; }
	num operator - (const num& r) const { return num(*this) -= r; }
	num operator * (const num& r) const { return num(*this) *= r; }
	num pow(int b) const {
		num r = 1, a = *this;
		while (b) {
			if (b & 1) {
				r *= a;
			}
			a *= a;
			b /= 2;
		}
		return r;
	}
	num inv() const { return pow(MOD - 2); }
};
using num = modnum<int(1e9) + 7>;

const int MAXN = 2010;
const int MAXD = MAXN * MAXN;
int N, K;
bool used[MAXN][MAXN];
num dp[MAXN][MAXN];
num fact[MAXD], ifact[MAXD];

void precomp() {
	fact[0] = 1;
	for (int i = 1; i < MAXD; i++) {
		fact[i] = num(i) * fact[i-1];
	}
	ifact[MAXD-1] = fact[MAXD-1].inv();
	for (int i = MAXD-2; i >= 0; i--) {
		ifact[i] = num(i+1) * ifact[i+1];
	}
}

num C(int a, int b) {
	return fact[a] * ifact[b] * ifact[a-b];
}

num go(int a, int b) {
	if (a > N || b > N || a < b) return num(0);
	if (!used[a][b]) {
		used[a][b] = true;
		dp[a][b] = go(a+1, b) + go(a, b+1) * C(N*K - a - b*(K-1) - 1, K-2);
	}
	return dp[a][b];
}

int main() {
	precomp();
	cin >> N >> K;
	if (K == 1) { puts("1"); return 0; }
	used[N][N] = true;
	dp[N][N] = 1;
	num ans = fact[N] * go(0, 0);
	cout << ans.v << endl;

	return 0;
}


Measured memory_bytes: 51840
import sys
from io import StringIO
import unittest
import math

def resolve():
    N,X, T = map(int, input().split())
    ans = math.ceil(N/X)*T
    print("{}".format(ans))
    

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """20 12 6"""
        output = """12"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1000 1 1000"""
        output = """1000000"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 71104
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S;
  cin>>S;
  vector<int> arr;
  bool nowr = true;
  arr.push_back(0);
  for(int i=1;i<S.size();++i) {
    if(nowr && S[i]=='L') {
      nowr = false;
      arr.push_back(i);
    }
    else if(!nowr && S[i]=='R') {
      nowr = true;
      arr.push_back(i);
    }
  }
  map<int, int> amap;
  int index;
  for(int i=0;i<S.size();++i) {
    if(S[i]=='R') {
      index = upper_bound(arr.begin(), arr.end(), i)-arr.begin();
      if((i-arr[index])%2==0) amap[arr[index]]++;
      else amap[arr[index]-1]++;
    }
    else {
      index = upper_bound(arr.begin(), arr.end(), i)-arr.begin()-1;
      if((i-arr[index])%2==0) amap[arr[index]]++;
      else amap[arr[index]-1]++;
    }
  }
  for(int i=0;i<S.size();++i) {
    cout<<amap[i]<<" ";
  }
  cout<<endl;
}



Measured memory_bytes: 8400
sa = input()
sb = input()
sc = input()

turn = "a"
while 1:
    if turn == "a":
        if not sa:
            print("A")
            exit()
        else:
            turn = sa[0]
            sa = sa[1:]
    if turn == "b":
        if not sb:
            print("B")
            exit()
        else:
            turn = sb[0]
            sb = sb[1:]
    if turn == "c":
        if not sc:
            print("C")
            exit()
        else:
            turn = sc[0]
            sc = sc[1:]


Measured memory_bytes: 3064
/**
*
* Author: MARC
* Lang: GNU C++14
*
**/

#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >

typedef unsigned long long ull;
typedef long double ldbl;
typedef long long ll;
typedef double dbl;

const ldbl E = 2.71828182845904523536;
const ldbl pi = acos(-1);
const dbl eps = 1e-9;
const ll mod = 1e9+7;
const ll inf = 1LL<<30;

/** /////////// ** Code ** /////////// **/

const int N=100100;
map<int,int>mp;

int main()
{
    int n; scanf("%d",&n);
    for(int i=0 ; i<n ; i++){
        int x; scanf("%d",&x);
        mp[x]++;
    }

    int ans=0;

    for(auto x:mp) if((x.S)&1) ans++;

    printf("%d",ans);
}


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

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

  int a[9];
  for (int i = 0; i < 9; i++) {
    cin >> a[i];
  }
  int n;
  bool judge = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int m; cin >> m;
    for (int j = 0; j < 9; j++) {
      if (m == a[j]) {
        a[j] = -1;
      }
    }
  }
  for (int i = 0; i < 3; i++) {
    if (a[0+i] == -1 && a[3+i] == -1 && a[6+i] == -1) {
      judge = 1;
    }
  }
  for (int i = 0; i < 9; i += 3) {
    if (a[0+i] == -1 && a[1+i] == -1 && a[2+i] == -1) {
      judge = 1;
    }
  }
  if ((a[0] == -1 && a[4] == -1 && a[8] == -1) || (a[2] == -1 && a[4] == -1 && a[6] == -1)) {
    judge = 1;
  }
  if (judge) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.math.BigInteger;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int n = Integer.parseInt(reader.readLine());
        for (int i = 0; i < n; i++) {
            BigInteger a = new BigInteger(reader.readLine());
            BigInteger b = new BigInteger(reader.readLine());
            String result = "overflow";
            if (!isOverflow(a) && !isOverflow(b)) {
                BigInteger c = a.add(b);
                if (!isOverflow(c)) {
                    result = c.toString();
                }
            }
            out.println(result);
        }
    }
    
    static boolean isOverflow(BigInteger bi) {
        return bi.abs().toString().length() > 80;
    }
}

Measured memory_bytes: 9784
import sys

def print_arr(arr):
	for i in range(len(arr)):
		sys.stdout.write(str(arr[i]))
		if i != len(arr) - 1:
			sys.stdout.write(' ')
	print()

n = int(input())
arr = list(map(int, input().split()))

count = 0
for i in range(n):
	for j in range(n - 1, i, -1):
		if arr[j] < arr[j-1]:
			temp = arr[j]
			arr[j] = arr[j-1]
			arr[j-1] = temp
			count += 1

print_arr(arr)
print(count)


Measured memory_bytes: 5612
//kuch tho karna hai 
#include<bits/stdc++.h>
using namespace std;  
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n; i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  IOS;
  int T=1;
  // cin >> T;
  while(T--){
    int n ;
    cin >> n ;
    int x =0 ;
    fn{
      cin >> ar[i];
      x^=ar[i];
    }
    fn{
      cout << (x^ar[i])<<" ";
    }
  
  
  }
  return 0;
}

Measured memory_bytes: 5124
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        if(a == 1){
            System.out.println("Hello World");
        }
        else{
            System.out.println((int)s.nextInt() + (int)s.nextInt());
        }
    }
}

Measured memory_bytes: 21844