akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>

using namespace std;

int hantei(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy) {
	double y,m,n,d;
	if ((bx-ax==0 && dx-cx==0) || (by-ay==0 && dy-cy==0)) return 0; 
	if (dx-cx!=0) m=(dy-cy)/(dx-cx);
	if (bx-ax!=0) n=(by-ay)/(bx-ax);
	if (ax==bx) {
        if (cy==dy && ((cy>ay && cy<by) || (cy>by && cy<ay)) && ((cx<ax && dx>ax) || (dx<ax && cx>ax))) return 1;
        y=cy+m*(ax-cx);
		if (((y>cy && y<dy) || (y>dy && y<cy)) && ((y>ay && y<by) || (y>by && y<ay))) return 1;
		return 0;} 
	if (cx==dx) {
		y=ay+n*(cx-ax);
		if (((y>cy && y<dy) || (y>dy && y<cy)) && ((y>ay && y<by) || (y>by && y<ay))) return 1;
		return 0;}
	d=(ay-cy+m*cx-n*ax)/(m-n);
	if (((d>cx && d<dx) || (d>dx && d<cx)) &&((d>ax && d<bx) || (d>bx && d<ax)))  return 1;
	return 0;
}

int main() {
	int n,f;
	double xp1,yp1,xp2,yp2,xp3,yp3,xk,yk,xs,ys;
	cin >> n;
	for (;n>0;n--) {
		cin >> xp1 >> yp1 >> xp2 >> yp2 >> xp3 >> yp3 >> xk >> yk >> xs >> ys;
        f=hantei(xp1,yp1,xp2,yp2,xk,yk,xs,ys)+hantei(xp2,yp2,xp3,yp3,xk,yk,xs,ys)+hantei(xp1,yp1,xp3,yp3,xk,yk,xs,ys);
		if (f==1) cout << "OK"; else cout << "NG";
		cout << endl;
	}
return 0;
	}

Measured memory_bytes: 1220
def main():
    while True:
        N = input()    
        if N == 0:
            break
        points = [Vector(map(int, raw_input().split())) for _ in xrange(N)]
        seq = [Vector([0, -1]), Vector([0, 0])]
        while len(points) != 0:
            pre = seq[-1] - seq[-2]
            points.sort(key=lambda x: abs(x-seq[-1]), reverse=True)
            #print points
            points.sort(key=lambda x: (x-seq[-1]).norm() * pre.norm())
            #print points
            p = map(lambda x: (x-seq[-1]).norm() * pre.norm(), points)
            #print pre, points
            #print "\n".join(map(str, reversed(zip(points, p))))
            seq += [points.pop()]
        print round(sum(abs(v2 - v1) for v1, v2 in zip(seq[1:], seq[2:])), 1)

class Vector(tuple):

    def __neg__(self):
        return Vector([-x for x in self])

    def __abs__(self):
        return sum(x ** 2 for x in self) ** 0.5

    def __add__(self, v):
        if len(self) != len(v):
            raise ValueError, "Same dimension is required."
        return Vector([x1 + x2 for x1, x2 in zip(self, v)])

    def __sub__(self, v):
        return self.__add__(-v)
    
    def norm(self):
        a = self.__abs__()
        return Vector([x / a for x in self])

    def __mul__(self,  v):
        """dot product"""
        if len(self) != len(v):
            raise ValueError, "Same dimension is required."
        #  return sum(x1 * x2 for x1, x2 in zip(self, v))
        return round(sum(x1 * x2 for x1, x2 in zip(self, v)), 14)

if __name__ == "__main__":
    main()

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N) {
    cin >> a.at(i);
  }
  vector<int> owner(N,-1);
  int turn = 0;	//0:A, 1:B
  rep(i,N) {
    int cand = -1;
    int cand_idx = -1;
    rep(j,N) {
      if(owner.at(j) >= 0) {
        continue;
      }
      int value = a.at(j);
      if ( cand <= value ) {
        cand = value;
        cand_idx = j;
      }
    }
    owner.at(cand_idx) = turn;
    
    //for next loop
    turn = 1 - turn;
  }
  int alice, bob;
  rep(i,N) {
    int player = owner.at(i);
    if ( player == 0 ) {
      //alice
      alice += a.at(i);
    }
    else if ( player == 1 ) {
      //bob
      bob += a.at(i);
    }
  }
  cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define Endl '\n'
typedef long long int lli;
typedef pair<int, int> ii;
void solve();
int main(int argc, char const *argv[]){
 	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
  solve();
}
void solve(){
  int n;
  cin>>n;
  lli sum = 0;
  for(int i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0)
      sum+=i;
  }

  cout<<sum<<Endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = (int)2e7 + 123, MOD = (int)1e9 + 7;

int n, m, f[N], ans;

int bin_pow(int a , int b){
    if (b == 0) return 1ll;
    if (b % 2 == 1) return (bin_pow (a, b - 1) * a) % MOD;
    else {
        int x = bin_pow (a, b / 2);
        return (x * x) % MOD;
    }
}

int cnk (int n, int k) {
    int x = f[n];
    int y = (f[k] * f[n - k]) % MOD;
    return (x * bin_pow (y, MOD - 2)) % MOD;
}

main() {
    cin >> n >> m;
    f[0] = 1;
    for(int i = 1; i <= 2e7; ++i) {
        f[i] = f[i - 1] * i;
        f[i] %= MOD;
    }
    for (int i = 0; i <= n; ++i) {
        int a = i;
        int b = n - (2 * a);
        if(a + (2 * b) == m && b >= 0) {
            ans += cnk(a + b, a) % MOD;
            ans %= MOD;
        }
    }
    cout << ans % MOD;
    return 0;
}

Measured memory_bytes: 156544
#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;
  string S;
  cin >>  N >> S;

  int ans = 0;
  rep(i,N-2){
    if (S.at(i)=='A' && S.at(i+1)=='B' && S.at(i+2)=='C'){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb  push_back
#define ppb pop_back
#define mp  make_pair
bool check(string str){
	ll n=str.size();
	for(ll i=0;i<n/2;++i){
		if(str[i]!=str[n-i-1])
			return false;
	}
	return true;
}
int main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	string str;
	cin>>str;
	ll n=str.size();
	if(check(str)&&check(str.substr(0,(n-1)/2))&&check(str.substr((n+1)/2,(n-1)/2)))
		cout<<"Yes\n";
	else cout<<"No\n";

}

Measured memory_bytes: 256
n = gets.strip.to_i
a = gets.strip.split.map(&:to_i)

vmin = Array.new(n+2,0)
vmax = Array.new(n+2,0)
n.downto(0) do |i|
    vmin[i] = a[i]+(vmin[i+1]+1)/2
    if i<=28
        vmax[i] = [a[i]+vmax[i+1], 2**i].min
    else
        vmax[i] = a[i]+vmax[i+1]
    end
    if vmin[i] > vmax[i]
        p -1
        exit
    end
end
1.upto(n) do |i|
    vmax[i] = [vmax[i], (vmax[i-1]-a[i-1])*2].min
    vmin[i] = [vmin[i],  vmin[i-1]-a[i-1]].max
    if vmin[i] > vmax[i]
        p -1
        exit
    end
end
ans = 0
(n+1).times {|i| ans+= vmax[i]}
p ans


Measured memory_bytes: 23188
public class Main{
  static int top;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int ba, i, tmp;
    String str;
    char[] ch;
    int[] la, ta;

    str = sc.next();
    ch = new char[str.length()];
    la = new int[10]; ta = new int[10];
    for(i = 0;i < str.length();i++)ch[i] = str.charAt(i);
    ba = sc.nextInt();

    top = 0;
    for(i = 0;i < str.length();i++){
      if(ch[i] >= '0' && ch[i] <= '9'){
        push(la, (int)(ch[i] - '0'));
      }else if(ch[i] == '+'){
        tmp = pop(la);
        push(la, tmp + (int)(ch[++i] - '0'));
      }else{
        tmp = pop(la);
        push(la, tmp * (int)(ch[++i] - '0'));
      }
    }

    top = 0;
    for(i = 0;i < str.length();i++){
      if(ch[i] >= '0' && ch[i] <= '9'){
        push(ta, (int)(ch[i] - '0'));
      }else if(ch[i] == '+'){
        i++;
        push(ta, (int)(ch[i] - '0'));
      }else{
        tmp = pop(ta);
        push(ta, tmp * (int)(ch[++i] - '0'));
      }
    }

    tmp = 0;
    for(i = 0;i < top;i++)tmp += ta[i];

    if(ba == la[0] && ba == tmp)out.println("U");
    else if(ba != la[0] && ba != tmp)out.println("I");
    else if(ba == la[0] && ba != tmp)out.println("L");
    else if(ba != la[0] && ba == tmp)out.println("M");

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int pop(int[] stack){
    return stack[--top];
  }

  private static void push(int[] stack, int a){
    stack[top++] = a;
    return;
  }
}

Measured memory_bytes: 17356
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | Node (y, l, r) ->
      if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> f x; doit l; doit r in
  doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> doit l; f x; doit r in
  doit t

let print t =
  inorder (fun e -> print_string " "; print_int e) t;
  print_newline ();
  preorder (fun e -> print_string " "; print_int e) t;
  print_newline ()

let find x t =
  let rec doit = function
    | Nil -> false
    | Node (y, _, _) when x = y -> true
    | Node (y, l, _) when x < y -> doit l
    | Node (_, _, r) -> doit r in
  doit t

let delete x t =
  let rec doit = function
    | Nil -> assert false
    | Node (y, l, r) ->
      if x = y then
        if l = Nil then r
        else if r = Nil then l
        else
          let rec balance = function
            | Nil -> assert false
            | Node (x, Nil, r) -> (x, r)
            | Node (x, l, r) ->
              let (m, l) = balance l in
              (m, Node (x, l, r)) in
          let (m, r) = balance r in
          Node (m, l, r)
      else if x < y then Node (y, doit l, r)
      else Node (y, l, doit r) in
  doit t

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let m = read_int () in
  let t = ref (create ()) in
  for _ = 0 to m - 1 do
    match read_line () |> split_on_char ' ' with
    | ["insert"; n] -> t := insert (int_of_string n) !t
    | ["find"; n] -> print_endline (if find (int_of_string n) !t then "yes" else "no")
    | ["delete"; n] -> t := delete (int_of_string n) !t
    | _ -> print !t
  done

Measured memory_bytes: 25332
#include <stdio.h>
#include <string.h>
int main(){
    int X,A,B;
    char s[80];
  	scanf("%s",s);
    X = atoi(s);
  	scanf("%s",s);
    A = atoi(s);
    scanf("%s",s);
    B = atoi(s);
    printf("%d",(X-A)%B);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

int main(){
    lli n,a,cnt=0;
    map<lli,lli> mp;
    lli i,j;
    cin>>n;
    rep(i,0,n){
        cin>>a;
        mp[a]++;
        if(mp[a]>1){
            cnt++;
        }
    }
    cout<<n-floor((cnt+1)/2)*2<<endl;
}


Measured memory_bytes: 6568
[n,m] = [int(i) for i in input().split()]
to_acc = [0] * (n+1)
for i in range(m):
  [l,r] = [int(j)-1 for j in input().split()]
  to_acc[l] += 1
  to_acc[r+1] -= 1
acc = [0]
ans = 0
for i in range(n+1):
  acc.append(acc[-1] + to_acc[i])
for i in range(1,n+1):
  if m == acc[i]:
    ans += 1
print(ans)

Measured memory_bytes: 81512
#include "bits/stdc++.h"

using namespace std;

int main() {
  int N;
  cin >> N;
  int mi = (int)1e9 + 10, rank = -1;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    if (b < mi) {
      mi = b;
      rank = a;
    }
  }
  cout << rank + mi << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
h = list(map(int,input().split()))
ab = [list(map(int,input().split())) for _ in range(m)]

t={}
for i in range(n):
    t[i+1]=True
for x in ab:
    if h[x[0]-1] > h[x[1]-1]:
        t[x[1]] = False
    elif h[x[0]-1] < h[x[1]-1]:
        t[x[0]] = False
    else:
        t[x[0]] = False
        t[x[1]] = False
c = 0
for y in t.values():
    if y:
        c += 1
print(c)

Measured memory_bytes: 42804
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<cstring>
using namespace std;

struct list{
	int num;
	list *left, *right;
};

list *nill;


void insert(int);
void init(void);
void deleteList(list *dl);
list *seachList(int);
void deleteFirst(void);
void deleteLast(void);
void listOutput(void);

int main(void){
	char c[50];
	int n;
	int s;
	scanf("%d", &s);
	init();
	for(int i = 0; i < s; i++){
		scanf("%s", c);
		if(c[0] == 'i'){
			scanf("%d", &n);
			insert(n);
		}
		else if(c[0] == 'd' && strlen(c) == 6){
			scanf("%d", &n);
			deleteList(seachList(n));
		}
		else if(c[6] == 'F'){
			deleteFirst();
		}
		else{
			deleteLast();
		}
	}
	listOutput();
	return 0;
}



void insert(int nu){
	list *p;
	p = (list*)malloc(sizeof(list));
	p->num = nu;

	p->right = nill->right;
	nill->right->left = p;
	nill->right = p;
	p->left = nill;
}

void init(void){
	nill = (list*)malloc(sizeof(list));
	nill->right = nill;
	nill->left = nill; 
}

list *seachList(int sl){
	list *x = nill->right;
	while(x != nill && x->num != sl){
		x = x->right;
	}
	return x;
}

void deleteList(list *dl){
	if(dl == nill) return;
	dl->left->right = dl->right;
	dl->right->left = dl->left;
	free(dl);
}

void deleteFirst(void){
	deleteList(nill->right);
}

void deleteLast(void){
	deleteList(nill->left);
}

void listOutput(void){
	list *y = nill->right;
	while(y != nill){
		if(y==nill->left){
			printf("%d\n", y->num);
		}
		else{
			printf("%d ", y->num);
		}
		y = y->right;
	}
}



Measured memory_bytes: 34452
#include <stdio.h>
#include <stdlib.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=0,tail=0,n;

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1)%LEN;
}

P dequeue(void){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}

int min(int a, int b){
  return a<b ? a:b;
}

int main(){
  int elaps=0,c,q,i;
  P u;
  scanf("%d %d",&n,&q);
  for(i=1;i<=n;i++){
    scanf("%s %d",&Q[i].name,&Q[i].t);
  }
  head=1,tail=n+1;

  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0)enqueue(u); 
    else{
      printf("%s %d\n",u.name,elaps);
    }
  }
  
  return 0;
}




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

int main(void) {
    constexpr long MOD = 1e9 + 7;
    long n, m;
    cin >> n >> m;
    vector<long> x(n);
    vector<long> y(m);
    for(auto &e: x) cin >> e;
    for(auto &e: y) cin >> e;

    long xs = 0;
    // | | ... |  |  ...  |
    // 0 1 ... i i+1 ... n-1
    for(long i=0; i<n-1; i++) {
        long t = x[i+1] - x[i]; t %= MOD;
        t *= i+1, t %= MOD;
        t *= n-(i+1), t %= MOD;
        xs += t, xs %= MOD;
    }

    long ys = 0;
    for(long i=0; i<m-1; i++) {
        long t = y[i+1] - y[i]; t %= MOD;
        t *= i+1, t %= MOD;
        t *= m-(i+1), t %= MOD;
        ys += t, ys %= MOD;
    }

    cout << (xs * ys % MOD) << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define lld long long int

int cmpAsc(const void* a, const void* b){
    int x = *(int*)a, y = *(int*)b;
    if(x > y){
        return 1;
    }
    if(x < y){
        return -1;
    }
    return 0;
}

int mid(int a, int b, int c){
    if((b<=a&&a<=c) || (c<=a&&a<=b)){
        return a;
    }
    if((a<=b&&b<=c) || (c<=b&&b<=a)){
        return b;
    }
    return c;
}

int max(int a, int b, int c){
    if(b<=a&&c<=a){
        return a;
    }
    if(a<=b&&c<=b){
        return b;
    }
    return c;
}

int min(int a, int b, int c){
    if(a<=b&&a<=c){
        return a;
    }
    if(b<=a&&b<=c){
        return b;
    }
    return c;
}

int main(){
    int n;
    scanf("%d", &n);
    int a[n], t[100001] = {0};
    rep(i, 0, n){
        scanf("%d", &a[i]);
        t[a[i]]++;
    }
    int buf = 0;
    rep(i, 1, 100001){
        if(t[i] > 1){
            buf += t[i] - 1;
        }
    }
    buf += buf%2;
    printf("%d", n-buf);

    return 0;
}

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




int solve() {
    
   int  s,p;
   cin>>s>>p;
   int m = max(s,p);
   if(s==m)
   {
    for(int i=0;i<m;i++)
    {
        cout<<p;
    }
    cout<<endl;
   }
   else
   {
    for(int i=0; i<m;i++)
    {
        cout<<s;
    }
    cout<<endl;
   }

}


int main()
{
    int test = 1, tc = 0;
    //scanf("%d", &test);
   // (void)getchar();
    //cin >> test;
    while (test--) {
        //printf("Case %d: ", ++tc);
        solve();
    }
    return 0;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    ll N; cin >> N;
    vector<ll> dp(111111, 0); // 出てきた回数をカウント
    ll ans = 0;
    REP(i, N) {
        ll A; cin >> A;
        dp[A]++;
        ans += A;
    }
    ll Q; cin >> Q;
    REP(i, Q) {
        ll B, C; cin >> B >> C;
        ll x = dp[B];
        ans += (C - B) * x;
        cout << ans << "\n";
        dp[C] += x;
        dp[B] = 0;
    }

}

Measured memory_bytes: 3980
import java.util.Scanner;
public class Main{

	public static void main(String[] args){

		Main main = new Main();
		main.solve();
	}

	private void solve() {

		Scanner sc = new Scanner (System.in);

		int N = sc.nextInt();

		int[] value = new int[N];
		int[] cost = new int [N];

		for (int index=0; index<N; index++) {
			value[index]=sc.nextInt();
		}

		for (int index=0; index<N; index++) {
			cost[index]=sc.nextInt();
		}

		int amount = 0;

		for (int index=0; index<N; index++) {
			if (value[index]-cost[index]>0) {
				amount+=value[index]-cost[index];
			}
		}

		System.out.println(amount);
	}
}

Measured memory_bytes: 22100
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto hw = readln.split.to!(int[]);
    auto H = hw[0];
    auto W = hw[1];

    char[][] MAP;
    MAP.length = H;
    foreach (i; 0..H) {
        MAP[i] = readln.chomp.to!(char[]);
    }

    int r;
    foreach (h; 0..H) {
        foreach (w; 0..W) {
            if (MAP[h][w] == '#') continue;
            auto memo = new bool[][](H, W);
            int t;
            int[2][] ss = [[h, w]];
            memo[h][w] = true;
            for (;;) {
                int[2][] nss;
                foreach (s; ss) {
                    foreach (d; [[1,0], [0,1], [-1,0], [0,-1]]) {
                        auto y = s[0] + d[0];
                        auto x = s[1] + d[1];
                        if (y < 0 || y >= H || x < 0 || x >= W || memo[y][x] || MAP[y][x] == '#') continue;
                        memo[y][x] = true;
                        nss ~= [y, x];
                    }
                }
                if (nss.empty) break;
                ++t;
                ss = nss;
            }
            r = max(r, t);
        }
    }
    writeln(r);
}

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

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
  double x=1,y=0;
	for(int i=0;i<n;i++) {
	  cin >> a.at(i); 
	  x*=a.at(i);
	}
	for(int i=0;i<n;i++) y+=x/a.at(i);
	cout << x/y << endl;
}


Measured memory_bytes: 256
import sys

n, a, b, c = map(int, sys.stdin.readline().split())
s = sys.stdin.read().split() + ['$$']

def main(a, b, c):
    res = []
    for i in range(n):
        x, y = s[i], s[i+1]
        if x == 'AB':
            if a == b == 0: break
            if a > b:
                a -= 1
                b += 1
                res.append('B')
            elif a < b:
                a += 1
                b -= 1
                res.append('A')
            else:
                if y == 'AC':
                    a += 1
                    b -= 1
                    res.append('A')
                else:
                    a -= 1
                    b += 1
                    res.append('B')
        elif x == 'AC':
            if a == c == 0: break
            if a > c:
                a -= 1
                c += 1
                res.append('C')
            elif a < c:
                a += 1
                c -= 1
                res.append('A')
            else:
                if y == 'AB':
                    a += 1
                    c -= 1
                    res.append('A')
                else:
                    a -= 1
                    c += 1
                    res.append('C')  
        elif x == 'BC':
            if b == c == 0: break
            if b > c:
                b -= 1
                c += 1
                res.append('C')
            elif b < c:
                b += 1
                c -= 1
                res.append('B')
            else:
                if y == 'AB':
                    b += 1
                    c -= 1
                    res.append('B')
                else:
                    b -= 1
                    c += 1
                    res.append('C')
    else:
        print('Yes')
        print(*res, sep='\n')
        return 
    print('No')
                
if __name__ == '__main__':
    main(a, b, c)

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; ++i) {
        cin >> a.at(i);
    }
    int res = 0;
    for (int i=0; i<n; ++i) {
        if (a.at(a.at(i)-1) == i+1) ++res;
    }
    cout << res / 2 << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 640
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
  int n, k;
  string s;

  cin >> n >> k >> s;


  --k;
  s[k] = s[k] - 'A' + 'a';
  cout << s << endl;
 
  return 0;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) {
  for (auto &e : vec) cout << e << " \n"[&e==&vec.back()];
}

template <class T>
void OUTS(vector<vector<T>> &df) {
  for (auto &vec : df) OUTS(vec);
}

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) {
  for (auto &e : vec) cout << e << "\n";
}

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int year, month, day;
  char c, c2;
  IN(year, c, month, c2, day);
  if (year <= 2019 && month <= 4 && day <= 30) OUTL("Heisei");
  else OUTL("TBD");
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
const ll mod = 1000000007;

using namespace std;

int n, m;
int s[2010], t[2010];
int dp[2010][2010];

signed main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int i = 0; i < m; i++) cin >> t[i];

    for (int i = 0; i <= 2009; i++) {
        for (int j = 0; j <= 2009; j++) {
            dp[i][j] = 1;
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
            dp[i][j] += mod - dp[i-1][j-1];
            if (s[i - 1] == t[j - 1]) dp[i][j] += dp[i - 1][j - 1];
            dp[i][j] %= mod;
        }
    }

    cout << dp[n][m] << endl;
}

// 共通部分列


Measured memory_bytes: 31872
#include <stdio.h>
using namespace std;
void trace(int a[],int n){//按顺序输出数组元素 
	int i;
	for(i=0;i<n;i++){
		if(i>0)	printf(" ");//在相邻元素之间输出一个空格
		printf("%d",a[i]); 
	}
	printf("\n");
}
void insertionSort(int a[],int n){
	int i,j,v;
	for(i=1;i<n;i++){
		v=a[i];//临时保存正待插入排序的元素 
		j=i-1;
		while(j>=0&&a[j]>v){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;
		trace(a,n);
	}
}
int main(){
	int n,i,j;
	scanf("%d",&n);
	int a[n];
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	trace(a,n);
	insertionSort(a,n);
	return 0;
} 


Measured memory_bytes: 2660
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
\
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;


int main() {
    int prev;
    int cur;
    int ans =0;
    int n;
    cin >> n;

    if(n == 2){
        cin >> cur;
        cout << 2*cur;
    }else {
        for (int i = 0; i < n - 1; i++) {
            cin >> cur;
            if (i == 0 || i == n - 2) ans += cur;
            if (i != 0) ans += min(prev, cur);

            prev = cur;
        }
        cout << ans;
    }
}







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

using namespace std;

typedef long long ll;

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

	string s;
	cin >> s;

	int n = s.size();

	cout << s.substr(0, 1);
	cout << n - 2;
	cout << s.substr(n-1, 1);
	cout << endl;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (auto &it: a) cin >> it;

    vector<int> dp(n, (int)1e9+11);
    dp[0] = 0;
    for (int i = 1; i < n; ++i) {
        for (int j = 1; j <= k; ++j) {
            if (i-j >= 0)
            dp[i] = min(dp[i], dp[i-j] + abs(a[i]-a[i-j]));
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

const string YES = "Yes";
const string NO = "No";

int main() {
    int D, T, S;
    cin >> D >> T >> S;
    if (D <= T * S) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
import java.util.Scanner;

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

        String s = sc.next() + sc.next();
        double num = Double.parseDouble(s);
        int root = (int)Math.sqrt(num);

        System.out.println(num == Math.pow(root, 2) ?  "Yes" : "No");
    }
}


Measured memory_bytes: 22100
n,m=map(int,input().split())
a=[i for i in range(n+1)]
b=[0]*(n+1)
def f(x):
    if a[x]==x:
        return x
    x=a[x]
    return(f(x))
def s(x,y):
    x=f(x)
    y=f(y)
    if x!=y:
        if b[x]<b[y]:
            a[x]=y
            b[y]+=1
        else:
            a[y]=x
            b[x]+=1
for i in range(m):
    c,d=map(int,input().split())
    s(c,d)
for i in range(1,n+1):
    a[i]=f(i)
d=a.count(a[2])
s=a.count(a[1])
print(max(((n-d)*(n-d-1)//2)-m+(d*(d-1)//2),((n-s)*(n-s-1)//2)-m+(s*(s-1)//2)))

Measured memory_bytes: 7984
#include <iostream>
#include <queue>
using namespace std;
 
   int main()
   {
        std::priority_queue<int> pq;
       int n, m;
        cin >> n >> m;
        for (int i = 0; i < n; i++) {
            int x;
            cin >> x;
            pq.push(x);
        }
        
        unsigned long long int sum = 0;
        while (!pq.empty()) {
            int t = pq.top();
            pq.pop();
            if(m > 0) {
                t = t / 2;
                pq.push(t);
                m--;
            } else {
                sum += t;
            }
        }
        
        cout<< sum << endl;
        return 0;
    }

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <map>
#include <utility>

using namespace std;
typedef pair<int, int> P;

struct UnionFind{
	struct UFNode{
		int id;
		int parent;
		int Enum, Vnum;
		int val;
		UFNode(){}
		UFNode(int id){
			this->id = id;
			parent = id;
			Enum = 0, Vnum = 1;
			val = 0;
		}
	};
	vector<UFNode> vec;
	vector<P> evec;
	map<int, int> mp;
	int ans;
	
	UnionFind(){ ans = 0; }
	int get(int i)
	{
		if(mp.count(i) == 0){
			vec.push_back(UFNode(i));
			mp[i] = (int)vec.size()-1;
		}
		return mp[i];
	}
	int root(int i){
		int pos = get(i);
		if(vec[pos].parent == i) return i;
		return vec[pos].parent = root(vec[pos].parent);
	}
	bool same(int i, int j){
		return root(i) == root(j);
	}
	void unite(int i, int j){
		int root_i = root(i), root_j = root(j);
		int posi = get(root_i), posj = get(root_j);
		vec[posi].Enum++;
		evec.push_back(make_pair(i, j));
		
		if(root_i == root_j){
			if(vec[posi].Enum <= vec[posi].Vnum) vec[posi].val++, ans++;
			return;
		}
		ans -= vec[posi].val + vec[posj].val;
		vec[posj].Enum += vec[posi].Enum;
		vec[posj].Vnum += vec[posi].Vnum;
		vec[posi].parent = root_j;
		vec[posj].val = min(vec[posj].Vnum, vec[posj].Enum);
		ans += vec[posj].val;
	}
};

int n, k;
vector<int> G[100005];
int c[100005], d[100005];
UnionFind uf[100005];
int ans[100005];

int dfs(int v, int p)
{
	int ret = v;
	uf[ret].unite(c[v], d[v]);
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == p) continue;
		int u = dfs(G[v][i], v);
		if(uf[ret].evec.size() < uf[u].evec.size()) swap(ret, u);
		for(int j = 0; j < uf[u].evec.size(); j++){
			//cout << ret << " " << uf[u].evec[j].first << " " << uf[u].evec[j].second << endl;;
			uf[ret].unite(uf[u].evec[j].first, uf[u].evec[j].second);
		}
	}
	ans[v] = uf[ret].ans;
	
	//cout << v << " : ";
	//for(int i = 0; i < uf[ret].vec.size(); i++) cout << uf[ret].vec[i].id << "[" << uf[ret].vec[i].val << "] "; cout << endl;
	
	return ret;
}

int main(void)
{
	cin >> n >> k;
	int u, v;
	for(int i = 1; i <= n-1; i++){
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for(int i = 1; i <= n; i++) cin >> c[i] >> d[i];
	
	dfs(1, -1);
	
	for(int i = 1; i <= n; i++) cout << ans[i] << "\n";
	flush(cout);
	
	return 0;
}


Measured memory_bytes: 133100
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;
const int MAXN = 2005;

int n, m;
char str[MAXN][MAXN];
int match[MAXN];
int main(){
	cin >> n >> m;
	int ans = n;
	for(int i=0; i<n; i++) scanf("%s",str[i]);
	for(int i=0; i<n; i++){
		for(int j=0; j<m-1; j++){
			if(i == 0) match[j] = 1;
			else if(i > 0 && (str[i-1][j] ^ str[i-1][j+1] ^ str[i][j] ^ str[i][j+1])) match[j] = 1;
			else match[j]++;
		}
		stack<int> stk;
		for(int j=0; j<=m-1; j++){
			while(!stk.empty() && match[stk.top()] >= match[j]){
				int l = stk.top();
				stk.pop();
				int h = j - (stk.empty() ? -1 : stk.top());
				ans = max(ans, h * match[l]);
			}
			stk.push(j);
		}
	}
	cout << ans << endl;
}



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

#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

int main() {

    long long int a, b, n;
    cin >> a >> b >> n;

    cout << a * min( b-1, n ) / b << endl;

    return 0;

}


Measured memory_bytes: 3472
sixexp=[6**i for i in range(1,7)]
nineexp=[9**i for i in range(1,6)]
lis=[1]+sixexp+nineexp

n=int(input())

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

for i in range(1,n+1):
    for j in lis:
        if i-j>=0:
            dp[i]=min(dp[i],dp[i-j]+1)

print(dp[n])

Measured memory_bytes: 3956
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var zennbu = Console.ReadLine().Split();
    var N = int.Parse(zennbu[0]);
    var M = int.Parse(zennbu[1]);
    var syurui = new List<int>();
    var a = Console.ReadLine().Split();
    foreach(var n in a){
      syurui.Add(int.Parse(n));
    }
    int goukei = syurui.Sum();
    int ikeru = 0;
    var ookii = syurui.OrderByDescending(x => x).ToList();
    for(var i = 0;i<M;i++){
       if(ookii[i]*4*M >= goukei){
      
       }
       else{
          ikeru = 1;
          Console.WriteLine("No");
          return;
       }
    }
    if(ikeru == 0){
      Console.WriteLine("Yes");
    }
    
   
  }
}

Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <iomanip>
#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 = uint32_t;
using namespace std;

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

using real = double;
real EPS = 1e-10;
struct Point {
    real x, y;
    Point& operator+=(const Point a) { x += a.x; y += a.y;  return *this; }
    Point& operator-=(const Point a) { x -= a.x; y -= a.y;  return *this; }
    Point& operator*=(const real k) { x *= k; y *= k;  return *this; }
    Point& operator/=(const real k) { x /= k; y /= k;  return *this; }
    Point operator+(const Point a) const {return Point(*this) += a; }
    Point operator-(const Point a) const {return Point(*this) -= a; }
    Point operator*(const real k) const {return Point(*this) *= k; }
    Point operator/(const real k) const {return Point(*this) /= k; }
    bool operator<(const Point &a) const { return (x != a.x ? x < a.x : y < a.y); }
    explicit Point(real a = 0, real b = 0) : x(a), y(b) {};
};

istream& operator>> (istream& s, Point& P){
    s >> P.x >> P.y;
    return s;
}

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

static constexpr int COUNTER_CLOCKWISE = 1;
static constexpr int CLOCKWISE = -1;
static constexpr int ONLINE_BACK = 2;
static constexpr int ONLINE_FRONT = -2;
static constexpr int ON_SEGMENT = 0;

int ccw(Point a, Point b, Point c){
    b -= a; c -= a;
    if(cross(b, c) > EPS) return COUNTER_CLOCKWISE;
    if(cross(b, c) < -EPS) return CLOCKWISE;
    if(dot(b, c) < 0) return ONLINE_BACK;
    if(abs(b) < abs(c)) return ONLINE_FRONT;
    return ON_SEGMENT;
}
struct Segment {
    Point a, b;
    Segment(Point x, Point y) : a(x), b(y) {};
};

double distance(Segment l, Point c){
    if(dot(l.b-l.a, c-l.a) < EPS) return abs(c-l.a);
    if(dot(l.a-l.b, c-l.b) < EPS) return abs(c-l.b);
    return abs(cross(l.b-l.a, c-l.a)) / abs(l.a-l.b);
}

bool intersect(Segment l1, Segment l2){
    return (ccw(l1.a, l1.b, l2.a)*ccw(l1.a, l1.b, l2.b) <= 0 &&
            ccw(l2.a, l2.b, l1.a)*ccw(l2.a, l2.b, l1.b) <= 0);
}

Point crossPoint(Segment l1, Segment l2){
    real d1 = abs(cross(l1.b-l1.a, l2.b-l2.a));
    real d2 = abs(cross(l1.b-l1.a, l1.b-l2.a));
    if(d1 < EPS && d2 < EPS) return l2.a;
    return l2.a+(l2.b-l2.a)*d2/d1;
}

int main() {
    Point p, q;
    cin >> p >> q;
    int Q; cin >> Q;
    for (int i = 0; i < Q; ++i) {
        Point r;
        cin >> r;
        int ans = ccw(p, q, r);
        if(ans == COUNTER_CLOCKWISE) puts("COUNTER_CLOCKWISE");
        if(ans == CLOCKWISE) puts("CLOCKWISE");
        if(ans == ONLINE_BACK) puts("ONLINE_BACK");
        if(ans == ONLINE_FRONT) puts("ONLINE_FRONT");
        if(ans == ON_SEGMENT) puts("ON_SEGMENT");
    }
    return 0;
}


Measured memory_bytes: 3200
/******tech_knight18_@7******/
/*I'm_not_the_only_traveller*/
/*who_has_not_repaid_his_debt*/
/*Take_me_back_to_The_Night_We_Met*/
#include<bits/stdc++.h>
using namespace std;
#define lld               long long int
#define ld                long double
#define pb                push_back
#define ppb               pop_back
#define mp                make_pair
#define F                 first
#define S                 second
#define nl                '\n'
#define all(c)            (c).begin(),(c).end()
#define rall(c)           (c).rbegin(),(c).rend()
#define sz(c)             (c).size()
#define tr(x,a)           for(auto &a : x)
#define psnt(x,a)         (x).find(a)!=(x).end()
#define vpsnt(x,a)        find(all(x),a)!=(x).end()
#define lexichar(x,y)     lexicographical_compare(x,x+strlen(x),y,y+strlen(y)) //modify the ranges
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()) 
#define MOD               1000000007
#define pi                3.1415926536
#define tod               1
#define itr(i,a,b)        for(lld i=a;i<=b;i++)
#define itrn(i,a,b)       for(lld i=a;i>=b;i--)
#define iot(n)            for(lld i=0;i<n;i++)
#define pls(n,arr)        lld arr[n]; iot(n)  cin>>arr[i];
#define bye               fflush(stdout)

typedef pair<lld,lld>     pii;
typedef pair<string,lld>  psi;
template <typename T>
bool mycomp(T x,T y){ 
   return (x==y);  //give your condition here
}
bool paircomp(const pair<lld,lld> &x,const pair<lld,lld> &y){ 
return x.second<y.second;
}

int main(){
       ios_base::sync_with_stdio(false);
             cin.tie(0);
            cout.tie(0);
      lld t=1; //cin>>t;  
     // map<string,lld> mp;
      while(t--){
          
          lld n; cin>>n;
          pls(n,a);
          sort(a,a+n,greater<lld>());
          lld sumr=a[0]; lld c=1,flag=0;
          itr(i,2,n-1){
              sumr+=a[c];
              flag++;
              if(flag==2) {
                  flag=0;
                  c++;
              }
          }
          cout<<sumr<<nl;
      }
}


Measured memory_bytes: 5204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   string s;
   cin>>s;

   long int ans = 0, sum = 0;
   for(auto ele : s){
   	if(ele == 'R'){
   		sum++;
   		ans = max(ans,sum);
   	}
   	else
   		sum = 0;
   }
   cout<<ans;
   return 0;
}

Measured memory_bytes: 3604
import math

def solve():
    A, B = [int(i) for i in input().split()]
    a = A / 0.08
    b = B / 0.1
    mi = min(a, b)
    ma = max(a, b)
    for i in range(math.floor(mi), math.ceil(ma) + 1):
        if int(i * 0.08) == A and int(i * 0.1) == B:
            print(i)
            exit()
    print(-1)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 62228
#include <bits/stdc++.h>
#include <string>
#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, a, b;
    cin >> n >> a >> b;

    int sum=0;
    for(int i=1; i<=n; i++) {
        string s=to_string(i);
        int ibuff=0;
        rep(i,s.size()) {
            ibuff += s[i]-'0';
        }
        if (a<=ibuff && ibuff<=b) {
            sum += i;
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3720
#include <stdio.h>
int main(){
	int n,k,x=1;
	int i;
	scanf("%d %d",&n,&k);
	for(i=0; i<n; i++){
		if(2*x < x+k){
			x *= 2;
		}else{
			x += k;
		}
	}
	printf("%d\n",x);
	return 0;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	string s ; cin >> s;
	string ans ="" ;
	rep(i,s.size()){
		char c = s[i];
		if(c == 'B' && ans.size()>0){
			ans.pop_back();
		}
		else if(c!='B'){
			ans += c;
		}
	}
	cout << ans << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
	#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	#define lli long long int
	#define ulli unsigned long long int
	#define ff first
	#define ss second
	#define mp make_pair
	#define pb push_back
	#define pf pop_front()
	#define lb lower_bound
	#define ub upper_bound
	#define bs binary_search
	#define rep(i,a,b) for(lli i=a;i<b;i++)
	#define repe(i,a,b) for(lli i=a;i<=b;i++)
	#define all(v) v.begin(), v.end()
	#define mod 1000000007
	#define inf 100000000000000000
	#define lld long double
	#define pll pair<long long int,long long int>
	#define pii pair<int,int>
	#define vll vector<lli>
	#define vii vector<int>
	#define endl '\n'
	#define pie  acosl(-1.0);
	#define setp(k, x) fixed << setprecision(k) << (x)
	#define deb(x) cerr << #x << ": " << x << " " << endl;
	#define debug(x) cout << "m here-" <<#x<<" ..."<<"\n";
	#define printa(a,n) for(lli i=0;i<n;i++) cout<<a[i]<<" "; cout<<"\n";
  #define printv(a) for(lli i=0;i<a.size();i++) cout<<a[i]<<" "; cout<<"\n";
	bool sortcol( const vector<lli>& v1, const vector<lli>& v2 ) //sort on basis of column //use- sort(vect.begin(), vect.end(),sortcol);
      { return v1[1] < v2[1]; }//[] o based indexing in column
	bool sortpair(const pair<lli, lli> &a, const pair<lli, lli> &b)
			{return a.second < b.second;}
	struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

//////////////////////////////////////////////////////////////////////////////////////////////
void solve();
//////////////////////////////////////////////////////////////////////////////////////////////



int main ()
{
	// fastio
 	// lli  t;
 	// cin>>t;
 	// while(t--)
 	{
	solve();

 	}
}
///////////////////////////////////////////
void solve()
{
	lli n,i,d,a,b,c,j,k;
  cin>>n;


  lli dp[n+1][3];
  dp[0][0]=dp[0][1]=dp[0][2]=0;
  vector <lli> arr[n+1];
  for( i = 1;i<=n;i++){
      cin>>a>>b>>c;
      arr[i].push_back(a);
      arr[i].push_back(b);
      arr[i].push_back(c);
  }
  for(i = 1;i<=n;i++){
      dp[i][0] = arr[i][0]+ max(dp[i-1][1] , dp[i-1][2] );
      dp[i][1] = arr[i][1]+ max(dp[i-1][0] , dp[i-1][2] );
      dp[i][2] = arr[i][2]+ max(dp[i-1][1] , dp[i-1][0] );
  }
  cout<< max(max(dp[n][0] , dp[n][1] ),dp[n][2] );


}


Measured memory_bytes: 9600
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;

int main()
{
    long long n,k;
    cin>>n>>k;
    long long mod1= n%k;
    
    long long mod2 = abs(mod1 -k);
    
    if(mod1<mod2){
        cout<<mod1;
    }else{
        cout<<mod2;
    }
    

    return 0;
}


Measured memory_bytes: 256