akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (long long i = 0; i < N; i++)
using ll = long long;

const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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 long long INF = 1LL << 60;

int main() {
    ll N;
    cin >> N;
    vector<ll> b(N + 1);
    b[0] = 0;
    for (ll i = 1; i <= N; i++) {
        cin >> b[i];
    }
    vector<ll> ans;
    for (ll i = 1; i <= N; i++) {
        ll rightIndex = -1;
        for (ll j = 1; j <= b.size() - 1; j++) {
            if (j == b[j]) {
                rightIndex = j;
            }
        }
        if (rightIndex == -1) {
            cout << -1 << endl;
            return 0;
        }
        ans.push_back(rightIndex);
        b.erase(b.begin() + rightIndex);
    }
    rep(i, N) {
        cout << ans.back() << endl;
        ans.pop_back();
    }
    return 0;
}


Measured memory_bytes: 256
//51
#include<iostream>

using namespace std;

int main(){
  for(int W,H;cin>>H>>W,W|H;){
    char g[100][100];
    for(int y=0;y<H;y++){
      for(int x=0;x<W;x++){
	cin>>g[y][x];
      }
    }
    int y=0,x=0;
    while(g[y][x]!='.'&&g[y][x]!='\0'){
      int ny=y+(g[y][x]=='v')-(g[y][x]=='^');
      int nx=x+(g[y][x]=='>')-(g[y][x]=='<');
      g[y][x]='\0';
      y=ny;
      x=nx;
    }
    if(g[y][x]){
      cout<<x<<' '<<y<<endl;
    }else{
      cout<<"LOOP"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>
#include <set>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;


int main(){
    int n;
    string s;
    int q;
    set<int> st[26];

    cin >> n >> s >> q;
    rep(i,n){
        int num = s[i] - 'a';
        st[num].insert(i+1);
    }
    rep(i,26){
        st[i].insert(n+1);
    }

    int f,pos;
    string c;
    int l,r;

    rep(i,q){
        cin >> f;
        if(f == 1) {
            cin >> pos >> c;
            int num = c[0] - 'a';
            int num2 = s[pos-1] - 'a';
            s[pos-1] = c[0];
            if(num != num2){
                st[num2].erase(pos);
                st[num].insert(pos);
            }
        }else{
            cin >> l >> r;
            int cnt = 0;
            
            rep(j,26){
                if(st[j].size() == 1){
                    if(l <= *st[j].begin() && *st[j].begin() <= r){
                        cnt++;
                    }
                }else if(st[j].size() > 1){
                    auto pos = st[j].lower_bound(l);
                    if(*pos <= r)cnt++;
                }
            }
            cout << cnt << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 24196
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, D) = Read2Longs();
            var X = new long[N];
            var Y = new long[N];
            for (int i = 0; i < N; i++)
            {
                (X[i], Y[i]) = Read2Longs();
            }

            var count = 0;
            for (int i = 0; i < N; i++)
            {
                if (Math.Sqrt(X[i] * X[i] + Y[i] * Y[i]) <= D)
                {
                    count++;
                }
            }

            return count;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


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

int main() {
	int A, B;
	cin >> A >> B;
	int x = A % 3;
	int y = B % 3;
	int z = (A + B) % 3;
	
	if (x == 0 || y == 0 || z == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, n) for(int i = n-1; i >= 0; i--)
#define rep4(i, x, n) for(int i = x; i > n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

int main(){
    ll A, B, C;
    cin >> A >> B >> C;
    if(C <= A+B+1) cout << B + C << endl;
    else cout << B + A+B+1 << endl;
}

Measured memory_bytes: 256
from sys import stdin, stdout
import math
inp = lambda : stdin.readline().strip()
   
n = int(inp())
ans = 0
for i in range(1, n):
    l = 1
    r = n
    while l < r:
        m = (l+r)//2
        if m*i >= n:
            r = m
        else:
            l = m+1
    ans += l-1
print(ans)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  int n;
  cin >> n;
  vector <int64_t> v(n);
  rep(i, n) cin >> v.at(i);
  int max = 0, tmp = 0;
  rep(i, n-1) {
    if (v.at(n-1-i) <= v.at(n-1-(i+1))) {
      tmp++;
    } else {
      if (tmp > max) {
        max = tmp;
      }
      tmp = 0;
    }
    if (tmp > max) {
      max = tmp;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES//(M_PIに使える（π）)

#include<stdio.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
#include<numeric>
#include<random>
#include <functional>
using namespace std;

int main() {
	string N ;
	int f = 0;
	cin >> N;
	for (int i = 0;i<N.size();i++) {
		if (N[i]=='9') {
			f = 1;
			break;
		}


	}
	if (f==1) {
		cout << "Yes"<< endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

using namespace std;

int main(void){
  int loop,op,num;
  vector<int> vec;
  cin>>loop;

  for(int i=0;i<loop;i++){
    cin>>op;
    switch(op){
      case 0:
      cin>>num;
      vec.push_back(num); break;
      case 1:
      cin>>num;
      cout<<vec.at(num)<<endl; break;
      case 2:
      vec.pop_back();
    }
  }
  return 0;
}



Measured memory_bytes: 3856
import sys

sys.setrecursionlimit(10**7)

inf = float('inf')

def solve():
    n = int(sys.stdin.readline())

    r = [0] * n
    c = [0] * n

    for i in range(n):
        ri, ci = map(int, sys.stdin.readline().split())
        r[i] = ri
        c[i] = ci

    memo = [[-1]*(n + 1) for i in range(n + 1)]

    ans = mcm(memo, n, r, c, 0, n)

    # print(memo)

    print(ans)

def mcm(memo, n, r, c, left, right):
    if memo[left][right] != -1:
        return memo[left][right]
    elif right - left == 1:
        memo[left][right] = 0
        return 0
    else:
        res = inf

        for i in range(left + 1, right):
            res = min(res, mcm(memo, n, r, c, left, i) + mcm(memo, n, r, c, i, right) + r[left]*r[i]*c[right-1])

        memo[left][right] = res
        return res

def compute_lcs(x, y):
    n = len(x)
    m = len(y)

    x = '#' + x
    y = '#' + y

    dp = [[0]*(m + 1) for i in range(n + 1)]

    for i in range(1, n + 1):
        for j in range(1, m + 1):
            if x[i] == y[j]:
                dp[i][j] = dp[i - 1][j - 1] + 1
            else:
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])

    return dp[n][m]

if __name__ == '__main__':
    solve()

Measured memory_bytes: 7852
n = int(input())
L = list(map(int, input().split()))

mul = 3 if L[-1] == n-1 else 6
MOD = 1000000007

ans = 1
zero_counter = 0
available = []
for elm in L:
    if elm == 0:
        zero_counter += 1
        if zero_counter > 3:
            ans = 0
            break
        available.append(elm)
    else:
        counter = available.count(elm-1)
        if counter == 0:
            ans = 0
            break
        ans *= counter
        available.remove(elm-1)
        available.append(elm)
        ans = ans % MOD

ans = (ans * mul) % MOD
print(ans)



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

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

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

int main() {
    int n;
    while(cin >> n, n){
        vector<int> a(n), b(n-1);
        for (auto &&i : a) scanf("%d", &i);
        for (auto &&j : b) scanf("%d", &j);
        sort(b.begin(),b.end(), greater<>());
        ll S = accumulate(a.begin(),a.end(), 0LL), ans = S*n;
        for (int i = 0; i < n-1; ++i) {
            S += b[i];
            ans = max(ans, (n-i-1)*S);
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3448
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ll long long

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

	int x, y, z, k;
	cin >> x >> y >> z >> k;

	ll a[x], b[y], c[z];
	for (int i = 0; i < x; ++i) cin >> a[i];
	for (int i = 0; i < y; ++i) cin >> b[i];
	for (int i = 0; i < z; ++i) cin >> c[i];

	sort(a, a + x, greater<ll>());
	sort(b, b + y, greater<ll>());
	sort(c, c + z, greater<ll>());

	vector<ll> sums;
	for (int i = 0; i < x; ++i) {
		for (int j = 0; j < y; ++j) {
			for (int l = 0; l < z; ++l) {
				if (i * j * l <= k) sums.push_back(a[i] + b[j] + c[l]);
			}
		}
	}
	sort(sums.begin(), sums.end(), greater<ll>());
	for (int i = 0; i < k; ++i) cout << sums[i] << '\n';
}


Measured memory_bytes: 35172
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a, b;
	cin >> a >> b;
	cout << 6 - a - b;













	return 0;
}


Measured memory_bytes: 256
a = int(input())
l = list(map(int, input().split()))

m = len(l)
lsort = sorted(l)
lmedlow = lsort[int(m/2)]
lmedhigh = lsort[int(m/2)-1]

for i in range (0, m):
	if l[i] < lmedlow:
		print(lmedlow)
	else:
		print(lmedhigh)

Measured memory_bytes: 25224
//object A {
object Main {
  import InOut._
  def main(args: Array[String]): Unit = {

    val a = nextInt

    out.println(a + a * a + a * a * a)

    out.flush()
  }
 
  final object InOut {
    val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)
    private[this] var tokenizer: java.util.StringTokenizer = _
    def nextToken: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new java.util.StringTokenizer(in.readLine)
      tokenizer.nextToken
    }
    def nextInt = Integer.parseInt(nextToken)
    def nextLong = java.lang.Long.parseLong(nextToken)
    def nextBig = BigInt(nextToken)
    def nextInts(n: Int) = Array.fill(n) { nextInt }
    def nextLongs(n: Int) = Array.fill(n) { nextLong }
    def nextBigs(n: Int) = Array.fill(n) { nextBig }
    def nextLine = in.readLine
  }
}


Measured memory_bytes: 54548
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

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

    int n,m;
    cin >> n >> m;
    vector<ll>x(n),y(n),z(n);
    for(int i = 0; i < n; i++) cin >> x[i] >> y[i] >> z[i];
    ll ans = 0;
    for(int bit = 0; bit < 8; bit++){
        vector<ll> tx = x;
        vector<ll> ty = y;
        vector<ll> tz = z;
        if(bit & 1){
            for(int i = 0; i < n; i++){
                tx[i] *= -1;
            }
        }
        if(bit & 2){
            for(int i = 0; i < n; i++){
                ty[i] *= -1;
            }
        }
        if(bit & 4){
            for(int i = 0; i < n; i++){
                tz[i] *= -1;
            }
        }

        vector<ll> sum(n);
        for(int i = 0; i < n; i++){
            sum[i] = tx[i] + ty[i] + tz[i];
        }
        sort(sum.begin(), sum.end(), greater<ll>());
        ll temp = 0;
        for(int i = 0; i < m; i++) temp += sum[i];
        if(temp > ans) ans = temp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
bingo = []
numbers = []
ans = 'No'

3.times do
  bingo << gets.split.map(&:to_i)
end

n = gets.to_i
n.times do
  numbers << gets.to_i
end

bingo.each do |row|
  flag = true
  row.each do |num|
    unless numbers.include?(num)
      flag = false
    end
  end
  if flag
    ans = 'Yes'
  end
end

columns = []
(0..2).each do |i|
  box = []
  bingo.each do |row|
    box << row[i]
  end
  columns << box
end

columns.each do |col|
  flag = true
  col.each do |num|
    unless numbers.include?(num)
      flag = false
    end
  end
  if flag
    ans = 'Yes'
  end
end

slash_flag = true
slash = [[bingo[0][0], bingo[1][1], bingo[2][2]], [bingo[0][2], bingo[1][1], bingo[2][0]]]
slash.each do |s|
  slash_flag = true
  s.each do |num|
    unless numbers.include?(num)
      slash_flag = false
    end
  end
  if slash_flag
    ans = 'Yes'
  end
end

puts ans


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		char [] letters = str.toCharArray();
		for(char c:letters) {
			if(c-3<'A') {
				System.out.printf("%c",c+23);
			}else {
				System.out.printf("%c",c-3);
			}
		}
		System.out.println();
		
	}
}



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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    int n,m;cin>>n>>m;
    if(n>=m){
        cout<<0<<endl;
        return 0;
    }else{
        V x(m);rep(i,m)cin>>x[i];
        sort(ALL(x));
        int dist=abs(x[m-1]-x[0]);
        V diff(m-1);
        
        rep(i,m-1){
            diff[i]=abs(x[i+1]-x[i]);
        }
        sort(RALL(diff));
        int ans=dist;
        rep(i,n-1){
            ans-=diff[i];
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 1024
# D
n, k = map(int, input().split())
s = list(input())
count = 0
lr = 0
rl = 0
for i in range(n - 1):
    if s[i] == "L":
        if s[i + 1] == "R":
            # LR
            lr += 1
        else:
            # LL 幸せ
            count += 1
    elif s[i + 1] == "L":
        # RL
        rl += 1
    else:
        # RR 幸せ
        count += 1
#LR,RLのどちらかが内側か判定(外側は見ていないので大きいのが内側)
a = max(rl, lr)
#内側の二倍が幸せになる人数
count += 2 * min(k, a)
#幸せになる人はn人にはならないのでn-1と最小をとる
print(min(count,n-1))

Measured memory_bytes: 4084
// Problem : B - Magic 2
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int a,b,c,k,t=0;
	cin >> a >> b >> c >> k;
	while(b <= a)
	b*=2,t++;
	while(c <= b)
	c*=2,t++;
	if(t <= k)
	cout << "Yes"<<"\n";
	else cout <<"No" <<"\n";
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


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

int main() {
    int n , ans;
    cin>>n;
    ans=(n+1000-1) / 1000;
    
    // if(ans==1000) cout<<0<<endl;

    cout<<ans*1000-n<<endl;
    
    return 0;
    
    
}

Measured memory_bytes: 3600
// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int N,a[22];
double dp[22][200010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N;
	rep(i,N)cin>>a[i];
	rep(i,N+1)rep2(j,1,200001)dp[i][j] = i ? INF : 0;
	rep(i,N)rep2(j,1,200001){
		dp[i][j] = max(dp[i][j], i ? fabs(a[i-1] - j)/a[i-1] : 0);
		for(int k = j; k <= 200000; k += j){
			dp[i+1][k] = min(dp[i+1][k], dp[i][j]);
		}
	}
	double ans = INF;
	rep2(j,1,200001)ans = min(ans, max(dp[N][j], fabs(a[N-1] - j)/a[N-1]));
	cout<<fixed<<setprecision(16)<<ans<<endl;
}

Measured memory_bytes: 34080
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  string s;
  cin >> s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl; 
  return 0;
}


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

#define ld long double
#define ll long long int
#define ull unsigned long long int
#define vi vector<int>
#define vl vector<ll>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define repd(i, a, b) for (int i=(a);i<(b);i++)
#define rep(i, n) repd(i,0,n)
#define ALL(v) v.begin(), v.end()
#define INF 1e9

using namespace std;

/**
 * calculate GCD(greatest common divisor)
 * @param a
 * @param b
 * @return
 */
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

/**
 * change minimum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMinimum(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * change maximum
 * @tparam T
 * @param a
 * @param b
 * @return bool
 */
template<class T>
inline bool changeMaximum(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/**
 * output answer
 * @tparam T
 * @param answer
 * @return
 */
template<typename T>
T output(T answer) {
    cout << answer << endl;
    return 0;
}

/** ----from here ---------------------------------------------------------- */

int main() {

    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i <N ; ++i) {
        cin>> a[i];
        
    }
    
    int ans = 0;
    
    for (int i = 1; i < N - 1; ++i) {
        int p1 = a[i - 1];
        int p = a[i];
        int p2 = a[i + 1];

        if(p < p1 && p > p2){
            ans++;
        }
        else if(p > p1 && p < p2){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

  int m,f,r;

  while(1){

    cin>>m>>f>>r;
    
    if(m==-1 && f==-1 && r==-1)return 0;

    if(m==-1 || f==-1)cout<<"F\n";
    else if(m+f>=80)cout<<"A\n";
    else if(m+f>=65 && m+f<80)cout<<"B\n";
    else if(m+f>=50 && m+f<65)cout<<"C\n";
	    else if(m+f>=30 && m+f<50){
	      if(r>=50)cout<<"C\n";
	      else cout<<"D\n";
	    }
	    else if(m+f<30)cout<<"F\n";
	    
	    }
  }
  

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main(){
  fastIO;
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> cost(n);
  vector<vector<int>> g(n);
  for(int i = 0 ; i < n; i ++ ){
    cin >> cost[i];
    g[i].resize(m);
    for(int j = 0 ; j < m ; j ++ ){
      cin >> g[i][j];
    }
  }
  int tot;
  int ans = (int)1e9;
  for(int i = 0 ; i < (1 << n); i ++ ){
    tot = 0;
    vector<int> cs(m);
    for(int j = 0 ; j < n; j ++ ){
      if((i&(1<<j))){
        tot += cost[j];
        for(int t = 0; t < m; t ++ )
          cs[t] += g[j][t];
      }
    }
    bool ok = true;
    for(int j = 0 ; j < m ; j ++ )
      if(cs[j] < x)
        ok = false;
    if(ok)
      ans = min(ans, tot);
  }
  if(ans == (int)1e9)
    cout << -1;
  else
  cout << ans << "\n";
  return 0;
}

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

using namespace std;
int main(){
	int n;
	cin>>n;
	int a,b,c;
	int dp[2][3];
	cin>>a>>b>>c;
	dp[0][0]=a; dp[0][1]=b;  dp[0][2]=c;
	dp[1][0]=0; dp[1][1]=0;  dp[1][2]=0;
	for(int i=1;i<n;i++){
		cin>>a>>b>>c;
		if(i%2==1){
		dp[1][0]=a+max(dp[0][1],dp[0][2]);
		dp[1][1]=b+max(dp[0][0],dp[0][2]);
		dp[1][2]=c+max(dp[0][1],dp[0][0]);}
		else {
		dp[0][0]=a+max(dp[1][1],dp[1][2]);
		dp[0][1]=b+max(dp[1][0],dp[1][2]);
		dp[0][2]=c+max(dp[1][1],dp[1][0]);}
			
	}
	int ans1=max(dp[1][0],max(dp[1][1],dp[1][2]));
	int ans2=max(dp[0][0],max(dp[0][1],dp[0][2]));
	cout<<max(ans1,ans2)<<endl;
}

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

namespace atcorder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strArray = Console.ReadLine().Split(' ');

            double A = Int64.Parse(strArray[0]);
            double B = Int64.Parse(strArray[1]);
            double K = Int64.Parse(strArray[2]);


            if( K < A )
            {
                double result = A - K;
                Console.WriteLine(result.ToString() + " " + B.ToString() );
                return;
            }
            else if ( K < A + B )
            {
                Console.WriteLine("0 " + ( B - ( K - A) ).ToString());
                return;
            }
            else
            {
                Console.WriteLine("0 0");
            }
        }
    }
}


Measured memory_bytes: 13140
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define DBG 1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define loop(n) rep(loop,(0),(n))
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, M; cin >> N >> M;
  int A=(N-M)*100+1900*M;
  cout<<A*pow(2,M)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 2005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
char mp[MAXN][MAXN];
char mp3[10][10]=
{
    "aab",
    "b.b",
    "baa"
};
char mp4[10][10]=
{
    "aaba",
    "ccba",
    "abcc",
    "abaa"
};
char mp5[10][10]=
{
    "aabbc",
    "hii.c",
    "h..jd",
    "g..jd",
    "gffee"
};
char mp6[10][10]=
{
    "aabbcc",
    "def...",
    "def...",
    "...fed",
    "...fed",
    "ccbbaa"
};
char mp7[10][10]=
{
    "aa.bb.c",
    ".ii..jc",
    "h.mm.j.",
    "h...n.d",
    ".l..n.d",
    "gl..kk.",
    "g.ff.ee"
};
vector<int> v;
void construct()
{
    int now=0;
    for(auto x:v)
    {
        for(int i=0;i<x;i++)
            for(int j=0;j<x;j++)
            {
                if(x==3) mp[now+i][now+j]=mp3[i][j];
                else if(x==4) mp[now+i][now+j]=mp4[i][j];
                else if(x==5) mp[now+i][now+j]=mp5[i][j];
                else if(x==6) mp[now+i][now+j]=mp6[i][j];
                else if(x==7) mp[now+i][now+j]=mp7[i][j];
            }
        now+=x;
    }
}
int main()
{
    scanf("%d",&n);
    int tmp=n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            mp[i][j]='.';
    if(n==2) {puts("-1"); return 0;} 
    else if(n==3) {v.push_back(3);}
    else if(n==7) {v.push_back(7);}
    else if(n==8) {v.push_back(4); v.push_back(4);}
    else if(n==4) {v.push_back(4);}
    else
    {
        if(n%3==1) {v.push_back(4); n-=4;}
        else if(n%3==2) {v.push_back(5); n-=5;}
        if(n%6==3) {v.push_back(4); v.push_back(5); n-=9;}
        for(int i=0;i<n/6;i++) v.push_back(6);
    }
    construct();
    for(int i=0;i<tmp;i++) printf("%s\n",mp[i]);
}

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

using namespace std;

int main()
{
  uint64_t N;
  cin >> N;
  
  vector<uint64_t> C(N), S(N), F(N);
  for (uint64_t n = 0; n < N; ++n) {
    cin >> C[n] >> S[n] >> F[n];
  }
  
  for (uint64_t n = 0; n < N; ++n) {
    uint64_t T = 0;
    for (int64_t m = n; m < N - 1; ++m) {
      if (T < S[m]) { // 始発が来ていないなら，それまで待つ
        T = S[m];
      } else {
        // S[m] + (i - 1) * F[m] < T < S[m] + i * F[m] なる i を見つける
        // <=> (i - 1) * F[m] < T - S[m] < i * F[m]
        // <=> i - 1 < (T - S[m]) / F[m] < i
        // <=> i = ceil[ (T - S[m]) / F[m] ]
        int64_t i = (T - S[m] + (F[m] - 1)) / F[m];
        T = S[m] + i * F[m];
      }
      
      T += C[m]; // 列車に乗って移動
    }
    cout << T << endl;
  }
  
  return 0;
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sfl(i,a,n) for (int i=a;i<n;i++)
#define ufl(i,a,n) for (int i=n-1;i>=a;i--)
#define SZ(x) ((int)(x).size())
#define endl '\n'
typedef long long ll;

ll power(ll a, ll b){
    ll res = 1;
    for(int i = 0; i<b; i++)
        res *= a;

    return res;
}

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}


int main()
{
    init();
    string s;
    cin >>s;
    long long n;
    cin >>n;
    int pos=0;
    while(pos<n)
    {
        if(s[pos]!='1')
        {
            pos++;
            break;
        }
        pos++;
    }
    cout <<s[pos-1];

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < (n); i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

int n, acu, uno, cero;
string s, t;
ll res;

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

	cin >> t;
	n = t.size();

	for (char c : t) {
		if (c == '1') {
			if (s.size() && s.back() == c) {
				uno += 2;
				s.pop_back();
			} else {
				s.pb(c);
			}
		} else {
			cero++;
			s.pb(c);
		}
	}

	res += 1ll * cero * uno / 2;

	forn (i, s.size()) {
		if (s[i] == '1') {
			res += cero - acu + (acu + 1 - i % 2) / 2;
			uno++;
		} else {
			acu++;
		}
	}

	while (uno) {
		res += (uno + 1) / 2;
		uno--;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3852
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
n,m=map(int,input().split())
j=0
l=[[] for _ in range(n)]
ans=[0]*m
for i in range(m):
    p,y=map(int,input().split())
    l[p-1].append((i,y,p))
for i in range(n):
    l[i].sort(key=lambda x:x[1])
for i in range(n):
    for j in range(len(l[i])):
        ans[l[i][j][0]]='%012d' %(l[i][j][2]*10**6+j+1)
print(*ans)

Measured memory_bytes: 86176
s=input()
a,b=int(s[:2]),int(s[2:])
if 1<= a <= 12 and 1<= b <= 12:
    print('AMBIGUOUS')
elif 1 <= a <= 12:
    print('MMYY')
elif 1 <= b <= 12:
    print('YYMM')
else:
    print('NA')

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

int main() {
    int N, average = 0;
    cin >> N;
    vector<int> a;
    for (int i = 0; i < N; i++) {
	int tmp;
	cin >> tmp;
	average += tmp;
	a.push_back(tmp);
    }
    average = roundf(((double) average) / N);

    int ans = 0;
    for (int i = 0; i < N; i++) {
	ans += (average - a[i]) * (average - a[i]);
    }
    cout << ans << endl;
    return 0;
}

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


using namespace std;

int main()
{
    string a,b;
    cin >> a;
    cin >> b;
    
    string r = a + a;
    
    for (int c = 0; c < a.size(); ++c) {
        if(r.substr(c,b.size()) == b ){
            cout << "Yes" << endl;
        	return 0;
        }
    }
    
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
#define ll long long
using namespace std;

ll mod(ll a)
{
    if(a<0){
        return -a;
    }else{
        return a;
    }
}

ll minimumCost(vector<ll> &v, ll cur,vector<ll> &dp)
{
    if(cur == v.size() - 1){
        return 0;
    }
    if(cur == v.size() - 2){
        return mod(v[cur] - v[cur + 1]);
    }
    if(dp[cur] != -1){
        return dp[cur];
    }

    ll cost1 = mod(v[cur] - v[cur + 1]) + minimumCost(v, cur + 1,dp);
    ll cost2 = mod(v[cur] - v[cur + 2]) + minimumCost(v, cur + 2,dp);

    dp[cur] = min(cost1, cost2);
    return min(cost1, cost2);
}

void solve()
{

    int n;
    cin >> n;

    vector<ll> h;
    vector<ll> dp(n + 1, -1);
    ll data;
    for (int i = 0; i < n; i++)
    {
        cin >> data;
        h.push_back(data);
    }
    cout << minimumCost(h, 0,dp) << endl;
}

int main()
{
    IOS;
    // int t;
    // cin >> t;
    // while (t > 0)
    {
        solve();
        // t--;
    }
    return 0;
}

Measured memory_bytes: 8180
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;b >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
const ll mod = (ll)1e9 + 7;
    
int main(){
    speed;
    long double a, b, c, d;
    cin >> a >> b >> c >> d;
    long double angle_m = (d/5.0) * 30;
    if(angle_m == 0) angle_m = 360; 
    vector<long double> v;
    c += ((double)d / 60.0);
    long double angle_h = c * 30;
    if(angle_h == 0) angle_h = 360;
    long double k;
    if(angle_h > angle_m) {
        k = angle_h - angle_m;
    } 
    else {
        k = angle_m - angle_h;
    }
    k = min(360 - k, k);
    long double res1 = (2 * a * b) * cos(k * M_PI / 180.0);
    printf("%0.15f",(double)sqrt(pow(a, 2) + pow(b,2) - res1));
   
    return 0;
}

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

int main() {
	int n, m, ans = 0;
	cin >> n >> m;
	vector<int> x(m);
	rep(i,m) cin >> x[i];
	sort(x.begin(), x.end());
	if (n < m) {
		vector<int> sa(m-1);
		rep(i, m-1) sa[i] = x[i+1] - x[i];
		sort(sa.begin(), sa.end());
		rep(i, m-n) ans += sa[i];
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3892
n = int(input())
s = input()
r = 0
b = 0
g = 0
for i in range(n):
    if s[i] == 'R':
        r += 1
    elif s[i] == 'B':
        b += 1
    else:
        g += 1

ans = r*g*b

for i in range(n):
    for j in range(i+1,n):
        if 2*j-i >= n:
            continue
        k = 2*j-i
        if s[i] != s[j]:
            if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                ans -= 1

print(ans)

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

int main(){
    int n, q;
    int64_t sum = 0;
    static int64_t cnt[100001];
    cin >> n;
    while(n--){
        int a;
        cin >> a;
        sum += a;
        ++cnt[a];
    }
    cin >> q;
    while(q--){
        int b, c;
        cin >> b >> c;
        sum -= cnt[b] * b;
        sum += cnt[b] * c;
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4304
n, m = map(int, input().split())
a = list(map(int, input().split()))
gokei = sum(a)
ln = 0
for i in range(n):
    if a[i] >= gokei/(4 * m):
        ln += 1
if ln >= m:
    print('Yes')
else:
    print('No')

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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

const int MOD = 998244353;
const ll INF = 1e18;
const int MX = 1000001;

int N, K, R, P, S;
str T;
ll ans;
bitset<100000> used;

int main() {
    used.reset();
	cin.sync_with_stdio(0); cin.tie(0);
    cin >> N >> K >> R >> S >> P >> T;
    F0R(i, N) {
        if (i < K) {
            if (T[i] == 'r') ans += P;
            if (T[i] == 's') ans += R;
            if (T[i] == 'p') ans += S;
            used[i] = 1;
        } else {
            if (T[i - K] == T[i] && used[i - K]) continue;
            else {
                if (T[i] == 'r') ans += P;
                if (T[i] == 's') ans += R;
                if (T[i] == 'p') ans += S;
                used[i] = 1;
            }
        }
    }
    
    cout << ans;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 512
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict
from operator import itemgetter, attrgetter
inf=float('inf')
mod = 10 ** 9 + 7
def combination(n, r):  # n個からr個選ぶ場合の数
    if n < r:
        return 0
    else:
        return factorial(n)//(factorial(r) * factorial(n-r))


def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N, A, B = MI()
    V = LI()
    v_dict = defaultdict(int)
    for v in V:
        v_dict[v] += 1
    VN = [(v, num) for v, num in v_dict.items()]
    VN.sort(reverse=True)
    A_copy = A
    ans_1 = 0
    for (v, n) in VN:
        if A_copy > n:
            A_copy -= n
            ans_1 += v*n
        else:
            ans_1 += A_copy * v
            break
    print(ans_1/A)
            
    if VN[0][1] > A:
        ans_2 = 0
        for choose_num in range(A, min(B, VN[0][1]) + 1):
            ans_2 += combination(n, choose_num)
        print(ans_2)
    else:
        for (v, n) in VN:
            if A > n:
                A -= n
            else:
                ans_2 = combination(n, A)
                break
        print(ans_2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38768
dict = {"1":0, "2":0, "3":0, "4":0}
for i in range(3):
    a, b = input().split()
    dict[a] += 1
    dict[b] += 1

cnt = 0    
for value in dict.values():
    if(value >= 2):
        cnt += 1
print("YES" if cnt >= 2 else "NO")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

const int N = 10000;
const int M = 10000*10000/2;

struct Node {
    int x, y;
    double d;
};

int n, m;
Node node[M+1];
int pre[N+1];
int rank[N+1];

bool cmp(const Node& a, const Node& b)
{
    return a.d > b.d;
}

void init()
{
    for (int i = 1; i <= n; i ++) {
        pre[i] = i;
        rank[i] = 0;
    }
}

int find(int a)
{
    while (a != pre[a])
        a = pre[a];
    return a;
}
void unite(int a, int b)
{
    a = find(a);
    b = find(b);
    if (a == b) return;
    if (rank[a] < rank[b]) {
        pre[a] = b;
    } else {
        pre[b] = a;
        if (rank[a] == rank[b])
            rank[a] ++;
    }
}

bool same(int a, int b)
{
    return find(a) == find(b);
}

double distance(int x1, int y1, int x2, int y2)
{
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

double kruskal()
{
    sort(node+1, node+m+1, cmp);
    double res = 0;
    for (int i = 1; i <= m; i ++) {
        int x = node[i].x, y = node[i].y;
        if (!same(x, y))
            unite(x, y);
        else
            res += node[i].d;
    }
    return res;
}

int main(void)
{
    int a[N+1], b[N+1];
    cin >> n >> m;
    for (int i = 1; i <= n; i ++) {
        scanf("%d%d", &a[i], &b[i]);
    }
    for (int i = 1; i <= m; i ++) {
        scanf("%d%d", &node[i].x, &node[i].y);
        int x = node[i].x, y = node[i].y;
        node[i].d = distance(a[x], b[x], a[y], b[y]);
    }
    init();
    printf("%.3lf\n", kruskal());

    return 0;
}

Measured memory_bytes: 1876
function Main(input) {
  const data = input.trim();
  const strs = data.split("");
  var result = "-1 -1";

  for (var i = 0; i < strs.length; i++) {
    if (strs[i] === strs[i + 2]) {
      result = `${i + 1} ${i + 3}`;
      break;
    } else if (strs[i] === strs[i + 1]) {
      result = `${i + 1} ${i + 2}`;
      break;
    }
  }
  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8268
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
  static String s;

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

    s = sc.next();
    int n = s.length();

    List< List< Integer > > at = new ArrayList< List< Integer > >(26);
    for(int i = 0; i < 26; i++){
      at.add(new ArrayList< Integer >());
    }

    for(int i = 0; i < n; i++){
      at.get(s.charAt(i) - 'a').add(i);
    }

    for(int i = 0; i < 26; i++){
      List< Integer > list = at.get(i);
      for(int j = 0; j + 1 < list.size(); j++){
        int count = 1;
        int l = list.get(j), m = list.get(j + 1);
        ++count;
        if(m - l >= 1 && 2 * count > m - l + 1){
          System.out.println((l + 1) + " " + (m + 1));
          return;
        }
      }
    }

    System.out.println("-1 -1");
  }
}

Measured memory_bytes: 16052
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

struct DisjointSet {
    private:
        vector<int> par;
        vector<int> rank;
    
    public:
        DisjointSet(int n) {
            par = vector<int>(n);
            rep(i, n) par[i] = i;
            rank = vector<int>(n);
        }
    
        int find(int i) {
            if (par[i] == i) return i;
            int p = find(par[i]);
            par[i] = p;
            return p;
        }
    
        bool joint(int i, int j) {
            int pi = find(i);
            int pj = find(j);
            if (pi == pj) return false;
    
            if (rank[pi] < rank[pj]) this->par[pi] = pj;
            else if (rank[pj] < rank[pi]) this->par[pj] = pi;
            else {
                this->par[pi] = pj;
                rank[pj]++;
            }
            return true;
        }
    };

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

    int n, q;
    cin>>n>>q;
    
    DisjointSet ds(n);
    rep(i, q) {
        int c, x, y;
        cin>>c>>x>>y;
        if (c == 0) {
            ds.joint(x, y);
        }
        else {
            if (ds.find(x) == ds.find(y)) cout<<1<<endl;
            else cout<<0<<endl;
        }
    }
}


Measured memory_bytes: 3256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int n, k; cin >> n >> k;
	string s; cin >> s;
	vector<int> nums;
	int now = 1;
	int cnt = 0;
	for (unsigned int i = 0; i < n; ++i) {
		if (s[i] == (char)(now + '0')) cnt++;
		else {
			nums.push_back(cnt);
			now = 1- now;
			cnt = 1;
		}
	}
	if (cnt != 0) nums.push_back(cnt);
	if (nums.size() % 2 == 0) nums.push_back(0);
	int add = 2 * k + 1;
	int ans = 0;
	vector<int> sum(nums.size() + 1, 0);
	for (int i = 0; i < nums.size(); ++i) {
		sum[i + 1] = sum[i] + nums[i];
	}
	for (int i = 0; i < nums.size(); i += 2) {
		int left = i;
		int right = min(i + add, (int)nums.size());
		int tmp = sum[right] - sum[left];
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 1272
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
        int[] list = new int[10];
        for (int i = 0; i < 10; i++) {
            list[i] = int.Parse(Reader.ReadLine());
        }
        list = list.OrderByDescending(a => a).ToArray();
        System.Text.StringBuilder ans = new System.Text.StringBuilder();
        for (int i = 0; i < 3; i++) {
            ans.AppendLine(list[i].ToString());
        }
        Console.Write(ans.ToString());

    }

    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"

1819
2003
876
2840
1723
1673
3776
2848
1592
922



";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
#define int long long
int expression(string,int&);
int term(string,int&);
int factor(string,int&);
int number(string,int&);

bool f;

int expression(string s,int& p){
  int res=term(s,p);
  while(p<(int)s.size()){
    if(s[p]=='+'){
      p++;
      res+=term(s,p);
      continue;
    }
    if(s[p]=='-'){
      p++;
      res-=term(s,p);
      continue;
    }
    break;
  }
  return res;
}

int term(string s,int& p){
  int res=factor(s,p);
  while(p<(int)s.size()){
    if(s[p]=='*'){
      p++;
      res*=factor(s,p);
      continue;
    }
    if(s[p]=='/'){
      p++;
      int tmp=factor(s,p);
      if(tmp==0){
	f=1;
	break;
      }
      res/=tmp;
      continue;
    }
    break;
  }
  return res;
}

int factor(string s,int& p){
  int res;
  if(s[p]=='('){
    p++;
    res=expression(s,p);
    p++;
  }else{
    res=number(s,p);
  }
  return res;
}

int number(string s,int& p){
  int res=0;
  while(p<(int)s.size()&&isdigit(s[p]))
    res=res*10+s[p++]-'0';
  return res;
}

signed main(){
  int n;
  cin>>n;
  while(n--){
    string s;
    int p=0;
    cin>>s;
    s.pop_back();
    cout<<expression(s,p)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3092