akhauriyash/Code-Regression huggingface dataset:
result = []
until (n = $<.gets.to_i).zero?
  teams = Array.new(n) do
    name, *nums = $<.gets.split
    po = nums.map(&:to_i).zip([3, 0, 1]).inject(0) {|acc, i| acc + i[0] * i[1]}
    [name, po]
  end.sort {|a, b| b[1] <=> a[1]}
  result << teams.map {|a| a.join(",") + "\n"}.join
end
puts result.join("\n")


Measured memory_bytes: 6876
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "\t" << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl << "\t", dump_func(__VA_ARGS__);
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
const int MOD = 1e9 + 7;

signed main() {
  struct Edge {
    int to, c;
  };
  int n; cin >> n;
  vector<vector<Edge>> G(n);
  REP (i, n - 1) {
    int s, t, w; cin >> s >> t >> w;
    G[s].push_back({t, w});
    G[t].push_back({s, w});
  }
  int ans = 0;
  function<int(int, int)> dfs = [&](int v, int p) {
    int ma = 0;
    for (Edge e: G[v]) if (e.to != p) {
      int tmp = dfs(e.to, v) + e.c;
      ans = max(ans, ma + tmp);
      ma = max(ma, tmp);
    }
    return ma;
  };
  dfs(0, -1);
  cout << ans << endl;
}



Measured memory_bytes: 19232
const MAX: usize = 4001;
fn main() {
    let (n, k): (usize, usize) = readln();
    let mut b = [[0i32; MAX]; MAX];
    let mut w = [[0i32; MAX]; MAX];
    for _ in 0..n {
        let (x, y, c): (usize, usize, String) = readln();
        let (bx, by) = (x % (2 * k), y % (2 * k));
        let (ex, ey) = (bx + k, by + k);
        if &c == "B" {
            b[by][bx] += 1;
            b[by][ex] -= 1;
            b[ey][bx] -= 1;
            b[ey][ex] += 1;
        } else {
            w[by][bx] += 1;
            w[by][ex] -= 1;
            w[ey][bx] -= 1;
            w[ey][ex] += 1;
        }
    }
    for y in 0..MAX {
        for x in 1..MAX {
            b[y][x] += b[y][x - 1];
            w[y][x] += w[y][x - 1];
        }
    }
    for y in 1..MAX {
        for x in 0..MAX {
            b[y][x] += b[y - 1][x];
            w[y][x] += w[y - 1][x];
        }
    }
    let mut ans = 0;
    for y in 0..2 * k {
        for x in 0..2 * k {
            let (bx, by) = (x, y);
            let (cx, cy) = ((x + k) % (2 * k), (y + k) % (2 * k));
            let mut s = 0;
            for b1 in &[0, 2 * k] {
                for b2 in &[0, 2 * k] {
                    s += w[by + b1][bx + b2];
                    s += w[cy + b1][cx + b2];
                    s += b[by + b1][cx + b2];
                    s += b[cy + b1][bx + b2];
                }
            }
            ans = max(ans, s);
        }
    }
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashSet;

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n {
        vs.push(readln());
    }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(
    String,
    bool,
    f32,
    f64,
    isize,
    i8,
    i16,
    i32,
    i64,
    usize,
    u8,
    u16,
    u32,
    u64
);
impl<T> FromLn for Vec<T>
where
    T: FromLn,
{
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 129404
#coding = utf-8
import math
a, b, c = map(float, raw_input().split())
h = b * math.sin(math.pi*c/180)
s = a * h / 2
x = math.sqrt(h**2 + (a-b*math.sin(math.pi*(90-c)/180))**2) 
l = a + b + x
#print "%.8f, %.8f, %.8f" % (s, l, h)
print "\n".join([str(s), str(l), str(h)])
#print "%.1f, %.1f, %.1f" % (s, l, h)

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

#define REP(i,n) for(int i=0;i<n;++i)
#define RREP(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,m,n) for(int i=m;i<n;++i)
#define RFOR(i,m,n) for(int i=m-1;i>=n;--i)
#define ALL(v) v.begin(),v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

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

using namespace std;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> p = { 2 };
	vector<bool> b(246913, false);
	b[2] = true;
	FOR(i, 3, 246913) {
		int flag = 1;
		REP(j,p.size()){
			if (i%p[j] == 0) flag = 0;
		}
		if (flag) {
			p.push_back(i);
			b[i] = true;
		}		
	}
	while (1) {
		int n;
		cin >> n;
		if (!n) break;
		int cnt = 0;
		FOR(i, n + 1, 2 * n + 1) {
			if (b[i]) cnt++;
		}cout << cnt << endl;

	}

	return 0; 
}

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

int main(){
	int K, S, ans=0;
	cin >> K >> S;
	for(int X=0;X<=K;X++){
		for(int Y=0;Y<=K;Y++){
			if(S-X-Y>=0&&S-X-Y<=K) ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        final int N = scan.nextInt();
        final int K = scan.nextInt();
        final int Q = scan.nextInt();
        
        int[] A = new int[Q];
        for(int i = 0; i < Q; i++){
            A[i] = scan.nextInt();
        }
        scan.close();
        int[] point = new int[N];
        for(int i = 0; i < N; i++){
            point[i] = 0;
        }
        for(int i = 0; i < Q; i++){
            point[A[i] - 1] += 1;
        }

        for(int i = 0; i < N; i++){
            if(K - (Q - point[i]) > 0){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }

    }
           
}


Measured memory_bytes: 54516
S = input()
N = len(S)
C = [0]*N
count = 0
idxl,idxm,idxr = 0,0,0
for i in range(N-1):
  if S[i] == "R" and S[i+1] == "L":
    idxm = i
  if (S[i] == "L" and S[i+1] == "R") or i == N-2:
    idxr = i if i < N-2 else N-1 #正しい？
    count = (idxr-idxl)+1
    nr = (idxm-idxl)+1
    nl = (idxr-idxm)
#    print(i,count,idxm,idxr)
    if count%2 == 0:
      C[idxm] = C[idxm+1] = count//2
    else:
      m = count//2
      if (nr > nl and nr%2 == 1) or (nr < nl and nl%2 == 0):
        C[idxm] = m+1
        C[idxm+1] = m
      else:
        C[idxm] = m
        C[idxm+1] = m+1
#    print(i,idxl,idxm,idxr)
    idxl = i+1
print(" ".join(map(str,C)))


Measured memory_bytes: 10484
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (long long  i = 0; i < (long long)(n); i++)






int main() {
	string s,k;
	cin >> s;
	if (s == "Sunny") {
		k = "Cloudy";
	}
	else if (s == "Cloudy") {
		k = "Rainy";
	}
	else if(s == "Rainy"){
		k = "Sunny";
	}
	
	
	cout << k<< endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int x,n;
  scanf("%d %d",&x,&n);
  if(n==0){
    printf("%d\n",x);
  }else{
  int p[n],i;
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }

  int j,flag;
  for(i=0;;i++){
    flag=0;
    for(j=0;j<n;j++){
      if(x-i==p[j]){
        flag++;
        break;
      }
    }
    if(flag==0){
      break;
    }
    for(j=0;j<n;j++){
      if(x+i==p[j]){
        flag++;
        break;
      }
    }
    if(flag==1){
      break;
    }
  }
  if(flag==0){
    printf("%d\n",x-i);
  }else if(flag==1){
    printf("%d\n",x+i);
  }
  }
  return 0;
}

Measured memory_bytes: 2152
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using edge = pair<int, ll>;
using graph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
	int n,m, T; cin >> n>> m>> T;
    string  ans = "No";
    if(n+m>=T){
        ans = "Yes";
    }
    cout << ans << endl;
}


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

int main()
{
  std::string cards[3];
  for (auto& card: cards)
  {
    std::cin >> card;
  }
  int turnToken = 0;
  while(cards[turnToken] != "")
  {
    int next = *(cards[turnToken].begin()) - 'a';
    cards[turnToken].erase(cards[turnToken].begin());
    turnToken = next;
  }
  switch (turnToken)
  {
  case 0:
    std::cout << "A" << std::endl;
    break;
  case 1:
    std::cout << "B" << std::endl;
    break;
  case 2:
    std::cout << "C" << std::endl;
  default:
    break;
  }
  return 0;
}

Measured memory_bytes: 256
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e18
#define mm 998244353

void solve(){
	int n; cin>>n;
	string s; cin>>s;
	int cntr[n]={0},cntg[n]={0}, cntb[n]={0};
	if(s[0]=='R') cntr[0]=1;
	if(s[0]=='G') cntg[0]=1;
	if(s[0]=='B') cntb[0]=1;
	ff(i,1,n-1){
		if(s[i]=='R') cntr[i] = cntr[i-1] + 1;
		else cntr[i] = cntr[i-1];
		if(s[i]=='G') cntg[i] = cntg[i-1] + 1;
		else cntg[i] = cntg[i-1];
		if(s[i]=='B') cntb[i] = cntb[i-1] + 1;
		else cntb[i] = cntb[i-1];
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(s[i]==s[j]) continue;
			int x=0;
			if(s[i]!='B' && s[j]!='B'){
				x = cntb[n-1]-cntb[j];
				if(2*j-i<n && s[2*j-i]=='B') x--; 
			}
			if(s[i]!='G' && s[j]!='G'){
				x = cntg[n-1]-cntg[j];
				if(2*j-i<n && s[2*j-i]=='G') x--; 
			}
			if(s[i]!='R' && s[j]!='R'){
				x = cntr[n-1]-cntr[j];
				if(2*j-i<n && s[2*j-i]=='R') x--; 
			}
			ans += x;
		}
	}
	cout<<ans<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 3656
import itertools
# N = 3
# P = [1, 3, 2]
# Q = [3, 1, 2]
#
# N = 8
# P = [7, 3, 5, 4, 2, 1, 6, 8]
# Q = [3, 8, 2, 5, 4, 6, 7, 1]
#
#
# N = 3
# P = [1, 2, 3]
# Q = [1, 2, 3]

N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))

def calculate(n,p,q):
    x = 0
    y = 0

    for index,ar in enumerate(itertools.permutations([i for i in range(1,n+1)],n)):
        if list(ar) == list(p):
            x = index

        if list(ar) == list(q):
            y = index

    if x >= y:
        print(x-y)
    else:
        print(y-x)
calculate(N,P,Q)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int c,q,i,j,z=0,k=1,m[1001][1001]={0},e[6][2]={0};
  for(i=0;i<6;i++){
    cin>>q>>c;
    if(q>c)m[q][c]++;
    else m[c][q]++;
  }
  for(i=0;i<1001;i++)for(j=0;j<1001;j++){
    if(m[i][j]){
      if(m[i][j]%2==0)for(c=0;c<m[i][j]/2;c++){e[z][0]=i;e[z++][1]=j;}
      else {e[z][0]=i;e[z++][1]=j;}
    }
  }
  if(e[0][0]!=e[2][1]||e[1][0]!=e[2][0]||e[0][1]!=e[1][1])k=0;
  if(k)cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}

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

int x[100001];
int res[100001];
int main() {
	string s; cin >> s;
	long long int len = s.length();
	
	int r=1,l=0;
	
	int cnt = 0;
	for (int i=0; i<len-1; ++i) {
        x[i]=0;
		if (s[i+1] == 'R') {
			if (s[i] == 'R') {
				r++;
				if (i==len-2) {
                  //cout << "R:"<<r << endl;
                  res[cnt]=r;
                  cnt++;
                }
			}
			if (s[i] == 'L') {
				//cout << "L:"<< l << endl;
                res[cnt]=l;
              	cnt++;
 				r=1;
				if (i==len-2) {
                  //cout << "R:"<<r << endl;
                  res[cnt]=r;
                  cnt++;
                }
			}
		}
		if (s[i+1] == 'L') {
			if (s[i] == 'L') {
				l++;
				if (i==len-2) {
                  //cout << "L:"<<l << endl;
	              res[cnt]=l;
                  cnt++;
                }
			}
			if (s[i] == 'R') {
				//cout << "R:"<<r << endl;
                res[cnt]=r;
              	cnt++;
				l=1;
				if (i==len-2) {
                  //cout << "L:"<<l << endl;
	              res[cnt]=l;
                  cnt++;
                }
			}
		}
	}
  	x[len-1]=0;
  	r = 0; l = 0;
	for (int i=0; i<cnt; i+=2) {
        //cout << res[i] << " " << res[i+1] << " ";
      	x[r+res[i]-1] = (res[i] - res[i]/2) + res[i+1]/2;
      	x[r+res[i]]   =  res[i]/2 + (res[i+1] - res[i+1]/2);
      	r += res[i] + res[i+1];
    }
  	//cout << endl;
	for (int i=0; i<len; ++i) {
        cout << x[i] << " ";
    }
  	cout << endl;
	
	return 0;
}


Measured memory_bytes: 1408
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End


/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template


signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Cins(T);
    char last = 'P';
    for(char& c:T){
        if(c=='P' || c=='D')cout << c;
        else cout << 'D';
    }
    cout << endl;
    return 0;
}

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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];

        int[] a = new int[m];
        int[] b = new int[m];
        for (int i = 0; i < m; i++)
        {
            int[] ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            a[i] = ab[0];
            b[i] = ab[1];
        }

        var list = new List<List<int>>();
        for (int i = 0; i < n; i++)
        {
            list.Add(new List<int>());
        }
        for (int i = 0; i < m; i++)
        {
            list[a[i] - 1].Add(b[i] - 1);
            list[b[i] - 1].Add(a[i] - 1);
        }

        var s = "Yes";
        var que = new Queue<int>();
        que.Enqueue(0);
        int[] ans = Enumerable.Repeat<int>(-1, n - 1).ToArray();
        while (que.Count > 0)
        {
            int i = que.Dequeue();
            for (int k = 0; k < list[i].Count; k++)
            {
                if (list[i][k] != 0)
                {
                    if (ans[list[i][k] - 1] == -1)
                    {
                        ans[list[i][k] - 1] = i + 1;
                        que.Enqueue(list[i][k]);
                    }
                }
            }
        }

        for (int i = 0; i < ans.Length; i++)
        {
            if (ans[i] == -1)
            {
                s = "No";
                break;
            }
        }

        // 出力
        if (s == "Yes")
        {
            Console.WriteLine(s);
            for (int i = 0; i < ans.Length; i++)
            {
                Console.WriteLine(ans[i]);
            }
        }
        else
        {
            Console.WriteLine(s);
        }
    }
}

Measured memory_bytes: 45600
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  bool prime[110000];
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    rep(i,110000)
      prime[i]=false;
    for(i=2;i<110000;i++){
      if(prime[i])continue;
      for(j=2;i*j<110000;j++)
	prime[i*j]=true;
    }
    int ans=0;
    int num=0;
   
    for(i=2;i<110000;i++){
      if(prime[i])continue;
      num++;
      ans+=i;
      if(num==n)break;
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3248
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;

char S[100001];
int main() {
	scanf("%s", S);
	int N;
	for (int i = 0;; i++) {
		if (S[i] == 0) {
			N = i;
			break;
		}
	}
	int*r = new int[N];
	for (int i = 0; i < N; i++)r[i] = 0;
	int V = -1;
	int even = 0, odd = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'R') {
			if (i % 2) {
				even++;
			}
			else {
				odd++;
			}
		}
		else {
			if (S[i - 1] == 'R') {
				V = i-1;
				if (V % 2) {
					r[V] += even;
					r[V + 1] += odd;
				}
				else {
					r[V] += odd;
					r[V + 1] += even;
				}
				even = 0;
				odd = 0;
			}
			r[V + ((i - V) % 2)]++;
		}
	}
	for (int i = 0; i < N; i++)printf("%d ", r[i]);
	return 0;
}

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

using namespace std;

int table[ 10 ][ 10 ];
int visited[ 10 ][ 10 ];
int n;

typedef pair<int, int> pii;

void print() {
  for ( int i = 1; i <= n; i++ ) {
	for ( int j = 1; j <= n; j++ ) {
	  cerr << visited[ i ][ j ] << ", ";
	}
	cerr << endl;
  }
  cerr << endl;
  for ( int i = 1; i <= n; i++ ) {
	for ( int j = 1; j <= n; j++ ) {
	  cerr << table[ i ][ j ] << ", ";
	}
	cerr << endl;
  }
  cerr << endl;
}

bool check() {
  for ( int i = 1; i <= n; i++ ) {
	for ( int j = 1; j <= n; j++ ) {
	  if ( visited[ i ][ j ] < 0 ) {
		return false;
	  }
	}
  }
  return true;
}

bool is_same_sum() {
  int sum_neg = 0;
  int sum_pos = 0;
  for ( int i = 1; i <= n; i++ ) {
	for ( int j = 1; j <= n; j++ ) {
	  if ( table[ i ][ j ] > 0 ) {
		sum_pos += table[ i ][ j ];
	  } else {
		sum_neg -= table[ i ][ j ];
	  }
	}
  }
  return sum_pos == sum_neg;
}

bool is_global_fin;

int dx[ 4 ] = { 0, 1, 0, -1 };
int dy[ 4 ] = { 1, 0, -1, 0 };
void dfs( vector<pii> &ss, int index, int local_sum, int y, int x ) {
  visited[ y ][ x ] = index;
  for ( int i = 0; i < 4; i++ ) {
	if ( is_global_fin ) return;
	int ny = y + dy[ i ];
	int nx = x + dx[ i ];
	if ( visited[ ny ][ nx ] < 0 &&
		 table[ ny ][ nx ] > 0 ) {
	  if ( local_sum + table[ ny ][ nx ] == -table[ ss[ index ].first ][ ss[ index ].second ] ) {
		visited[ ny ][ nx ] = index;
		if ( index + 1 == ss.size() && check() ) {
		  is_global_fin = true;
		} else {
		  dfs( ss, index + 1, 0, ss[ index + 1 ].first, ss[ index + 1 ].second );
		}
		if ( !is_global_fin ) {
		  visited[ ny ][ nx ] = -1;
		}
	  } else if ( local_sum + table[ ny ][ nx ] < -table[ ss[ index ].first ][ ss[ index ].second ] ) {
		dfs( ss, index, local_sum + table[ ny ][ nx ], ny, nx );
	  }
	}
  }
  visited[ y ][ x ] = -1;
}

bool solve( vector<pii> &ss ) {
  if ( !is_same_sum() ) {
	return false;
  } else {
	is_global_fin = false;
	dfs( ss, 0, 0, ss[ 0 ].first, ss[ 0 ].second );
	return is_global_fin;
  }
}  

int main() {
  while ( true ) {
	cin >> n;
	if ( n == 0 ) break;
	
	for ( int i = 1; i <= 8; i++ ) {
	  for ( int j = 1; j <= 8; j++ ) {
		table[ i ][ j ] = 0;
		visited[ i ][ j ] = -1;
	  }
	}
	vector<pii> ss;
	for ( int i = 1; i <= n; i++ ) {
	  for ( int j = 1; j <= n; j++ ) {
		cin >> table[ i ][ j ];
		if ( table[ i ][ j ] < 0 ) {
		  ss.push_back( make_pair( i, j ) );
		}
	  }
	}
	if ( solve( ss ) ) {
	  cout << "YES" << endl;
	} else {
	  cout << "NO" << endl;
	}
  }
}

Measured memory_bytes: 1196
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int a=stdIn.nextInt(),b=stdIn.nextInt();
		if(a==b) System.out.print("Draw");
		else if(a==1) System.out.print("Alice");
		else if(b==1) System.out.print("Bob");
		else if(a>b) System.out.print("Alice");
		else System.out.print("Bob");
	}
}

Measured memory_bytes: 25556
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb push_back
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int oo = 0x3f3f3f3f;
const int maxn = 100000 + 5;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for( ;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for( ; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

int n, m;
map<int, int> mp;

int main() {
#ifdef Wearry
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif

    n = read<int>();
    for(int i = 1; i <= n; ++i) {
        int x = read<int>();
        ++ mp[x];
    }
    m = read<int>(); 
    for(int i = 1; i <= m; ++i) {
        int x = read<int>();
        if(!mp[x]) return puts("NO"), 0;
        -- mp[x];
    }
    puts("YES");

    return 0;
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    vector<int>a(n);
    rep(i,n)cin>>a[i];

    int cnt=0,cnt2=0,cnt4=0;
    rep(i,n){
        if(a[i]%4==0)cnt4++;
        else if(a[i]%2==0)cnt2++;
        else cnt++;
    }

    if(cnt2!=0)cnt++;

    if(cnt<=cnt4+1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

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

  cout << c[0][0] << c[1][1] << c[2][2] << endl;

  return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
const int N=100005;
int fl,n,ans,dp[N],pre[N],nxt[N][3];
char s[N];
void up(int &x,int y){x=x-mod+y;x=(x<0)?x+mod:x;}
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	fl=1;
	for (int i=1;i<n;i++) fl&=(s[i]!=s[i+1]);
	if (fl) return puts("1"),0;
	for (int i=1;i<=n;i++) pre[i]=(pre[i-1]+(s[i]=='b')+1)%3;
	for (int i=n;i>=1;i--)
	{
		for (int j=0;j<=2;j++) nxt[i][j]=nxt[i+1][j];
		nxt[i][pre[i]]=i;
	}
	dp[0]=1;
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=2;j++)
		{
			int t=nxt[i][(pre[i-1]+j)%3];
			if (t) up(dp[t],dp[i-1]);
		}
		if (pre[i]==pre[n]) up(ans,dp[i]);
	}
	printf("%d\n",ans);
	return 0;
} 

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

int main(){

  int N, Q; cin >> N >> Q;
  vector<pair<int,int>> fromto(N-1);
  vector<pair<int,int>> ope(Q);
  
  vector<int> sol(N);
  
  for(int i=0; i<N-1; i++){
    cin >> fromto.at(i).first >> fromto.at(i).second;
  }
  sort(fromto.begin(), fromto.end());

  for(int i=0; i<Q; i++){
    cin >> ope.at(i).first >> ope.at(i).second;
  }
  sort(ope.begin(), ope.end());

  int j = 0;
  int k = 0;
  for(int i=0; i<N; i++){
    //i+1番目の頂点を考える
   
    while( j < ope.size() && ope.at(j).first == i+1){
      sol.at(i) += ope.at(j).second;
      j++;
    }
    while( k < fromto.size() && fromto.at(k).first == i+1){
      sol.at(fromto.at(k).second-1) += sol.at(i);
      k++;
    }  
    cout << sol.at(i) << ' ';
  }
    
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = unsigned long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;
int main() {
 int k,a,b;
  in(k>>a>>b);
  for(int i=a;i<=b;i++){
   if(i%k==0){
    out("OK");
     return 0;
   }
  }
  out("NG");
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;

namespace PaizaTest
{
    class Program
    {
        static void Main(string[] args)
        {

            var N = int.Parse(Console.ReadLine());
            var bossIdList = Console.ReadLine().Split().Select(int.Parse).ToList();

            var employeeArray = new int[N];

            for (int i = 0; i < bossIdList.Count; i++)
            {
                employeeArray[bossIdList[i] - 1]++;
            }

            foreach (var employee in employeeArray)
            {
                Console.WriteLine(employee);
            }
#if DEBUG
            Console.ReadLine();
#endif
        }
    }
}


Measured memory_bytes: 40136
using System;

namespace AttackSurvival
{
    class Program
    {
        static void Main(string[] args)
        {
            String input = Console.ReadLine();
            String[] spl = input.Split(' ');
            int N = int.Parse(spl[0]);
            int K = int.Parse(spl[1]);
            int Q = int.Parse(spl[2]);
            int[] A = new int[Q];
            for (int i = 0; i < Q; i++)
            {
                A[i] = int.Parse(Console.ReadLine());
            }

            int[] score = new int[N];
            for(int i = 0; i < N; i++)
            {
                score[i] = K;
            }
            for(int i = 0; i < Q; i++)
            {
                score[A[i] - 1]++;
            }
            for(int i = 0; i < N; i++)
            {
                score[i] -= Q;
                if (score[i] > 0)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }
    }
}


Measured memory_bytes: 16092
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        s: usize,
        w: usize,
    }

    if s<=w {
        println!("unsafe");
    } else {
        println!("safe");
    }

}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
using namespace std;
#define int    long long
#define pb     push_back
#define mp     make_pair
#define ff     first
#define ss     second
#define pqg    priority_queue<int,vector<int>,greater<int>>
#define mod    1000000007
#define inf    1e18
#define w(x)    int x; cin>>x; while(x--)
#define loop(i,a,n)		for(int i=a;i<n;i++)
#define rev_loop(i,a,n)	for(int i=n-1;i>=a;i--)
#define endl    "\n"
#define fast   	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int32_t main()
{
	fast;
	int n;
	cin >> n;
	int k = n%10;
	if(k == 2 or k==4 or k==5 or k==7 or k==9)puts("hon");
	else if(k == 0 or k==1 or k==6 or k==8)puts("pon");
	else puts("bon");
	return 0;
}
/*
	Created By Sunman :) <3 

*/


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

int main() {
	int x, y;
	cin >> x >> y;
	
    int ans = 2000000000;
	for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            int tx = (i ? -x : x);
            int ty = (j ? -y : y);
            if (tx <= ty) {
                if (i + j + ty - tx < ans) {
                    ans = i + j + ty - tx;
                }
            }
        }
    }

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


Measured memory_bytes: 3564
//created by pyoxiao on 2020/05/10
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
const int N = 2e5 + 7;
int n;
LL k;
vector<int> ver[N];
int v[N];
vector<int> cir;
void dfs(int x) {
    v[x] = 1;
    for(auto to : ver[x]) {
        //cout << to << "***";
        if(v[to]) {
            cir.pb(to); 
            int pos = to;
            while(pos != x) {
                pos = ver[pos][0];
                cir.pb(pos);
            } 
            return;
        }
        dfs(to);
        //cout << to << "***";
    }
}
void solve() {
    scanf("%d %lld", &n, &k);
    for(int i = 1; i <= n; i ++) {
        int x;
        scanf("%d", &x);
        ver[i].pb(x);
    }   
    dfs(1);
    //puts("");
    if(k <= n) {
        int pos = 1;
        while(k) {
            pos = ver[pos][0];
            k --;
        }
        printf("%d\n", pos);
        return;
    }
    int pos = 1;
    while(pos != cir[0] && k) {
        pos = ver[pos][0];
        k --;
    }
    //cout << k << '\n';
    int sz = cir.size();
    //cout << sz << '\n';
    LL turn = k / sz, now = k - turn * sz;
    //cout << now << '\n';
    printf("%d\n", cir[now]);
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 27856
import Control.Monad

solver::[Int]->Int
solver ls = (sum ls)-(div (maximum ls) 2)

main::IO()
main=do
  c<-getLine
  let n = read c
  d<-forM [1..n] (\_->do
                    s<-getLine
                    return (read s))
  print (solver d)


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

LL dx[] = {1, -1, 0, 0, -1, -1, 1, 1};
LL dy[] = {0, 0, 1, -1, -1, 1, -1, 1};

///**************************DONE****************************///

int main()
{
    int a, b;
    cin >> a >> b;

    cout << 6 - a - b << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int a[100010] ;
	int len=s.size() ;
	for(int i=0;i<len;i++){
			a[i]=1;
	}
	for(int i=0;i<len;i++) {
		int j=i;
		if(s[i]=='R') {
			while(s[i+1]=='R') a[i]=0,i++;
			int m=i-j;
			a[i]+=m/2;
			a[i+1]+=m/2+m%2;
		}
		else {
			while(s[i+1]=='L') a[i+1]=0,i++;
			int m=i-j;
			a[j]+=m/2;
			a[j-1]+=m/2+m%2;
		}
	}
	for(int j=0;j<len;j++)
				cout << a[j]<<" ";
			cout <<endl;
	return 0;
}

Measured memory_bytes: 1024
/*
 * FileName:     maximum_profit_fix_2
 * CreatedDate:  2020-07-14 00:06:00 +0900
 * LastModified: 2020-07-14 00:15:48 +0900
 */

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int n;scanf("%d", &n);
    long int *r = malloc(n*sizeof(long int));
    for(int i=0; i<n; i++)scanf("%ld", r+i);
    long int minv = r[0];
    long int maxv = -1000000000;
    long int ans = maxv-minv;
    for(int i=1; i<n; i++){
        maxv = r[i];
        if(maxv-minv>ans){
            ans = maxv - minv;
        }
        if(minv > r[i]){
            minv = r[i];
        }
    }
    printf("%ld\n", ans);
    free(r);
    return 0;
}



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

int main() {
  int n;
  string s;
  cin >> n;
  vector<int> vec{0, 0, 0, 0};
  for(int i = 0; i < n; i++) {
      cin >> s;
      if(s == "AC") {
        vec.at(0)++;
      }
      else if(s == "WA") {
        vec.at(1)++;
      }
      else if(s == "TLE") {
        vec.at(2)++;
      }
      else if(s == "RE"){
        vec.at(3)++;
      }
  }
  cout << "AC x " << vec.at(0) << endl;
  cout << "WA x " << vec.at(1) << endl;
  cout << "TLE x " << vec.at(2) << endl;
  cout << "RE x " << vec.at(3) << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		int n = sc.nextInt();
		int a = sc.nextInt();
		
		System.out.println(n % 500 <= a ? "Yes": "No");
	}
}


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

typedef long long ll;
int cnt[10][10];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	for(int i = 1;i <= n; ++i){
		int x = i;
		int f = x%10;
		int s;
		while(x){
			s = x % 10;
			x/=10;
		}
		++cnt[f][s];
	}
	ll ans = 0;
	for(int i = 0;i < 10; ++i){
		for(int j = 0;j < 10; ++j){
			ans += 1LL * cnt[i][j] * cnt[j][i];	
		}
	}
	cout << ans << '\n';
}


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

using namespace std;
using ll = long long;

int main() {
    int k = 0;
    string s = "";
    cin >> k >> s;

    if(k >= s.size()){
        cout << s <<endl;
    }else{
        for(int i = 0;i < k;i++){
            cout << s[i];
        }
        cout << "..." << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3624
N = int(input())
A,B = map(int,input().split())
P = list(map(int,input().split()))
x1,x2,x3 = 0,0,0
for i in range(N):
    if P[i]<=A:
        x1 += 1
    if P[i]>=A+1 and P[i]<=B:
        x2 += 1
    if P[i]>= B+1:
        x3 += 1
print(min(x1,x2,x3))

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

int main() {
    int n;
    cin >> n;
    string s = to_string(n);
    int sum = 0;
    for (char i : s) sum += i - '0';
    cout << (n % sum == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
main()
{
    int a,b,c,d,e;
    cin>>a;
    cin>>b;
    cin>>c;
    d=b-a;
    e=c-b;
    if(d==e)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    sum += A.at(i);
  }
  int cnt = 0;
  for(int i = 0; i < N; i++){
    if(A.at(i) * 4 * M >= sum) cnt++;
  }
  if(cnt >= M) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

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

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll h, w, K;
    cin>>h>>w>>K;
    vector<vector<char> > v(h, vector<char>(w));
    for(ll row = 0; row<h; row++){
        for(ll col =0; col<w; col++){
            cin>>v[row][col];
        }
    }
    ll ans = 0;
    for(ll i=0; i<(1ll<<(h)); i++){
        for(ll j=0; j<(1ll<<(w)); j++){
            ll rowMask = i;
            ll colMask = j;
            set<ll> rowSet;
            set<ll> colSet;
            ll cnt = 0;
            for(ll k=0; k<h; k++){
                if((rowMask&(1<<k))){
                    rowSet.insert((h-1-k));
                }
            }
            for(ll k=0; k<w; k++){
                if(colMask&(1<<k)){
                    colSet.insert((w-1-k));
                }
            }
            ll x = 0;
            for(ll row = 0; row<h; row++){
                if(rowSet.find(row)==rowSet.end()) continue;
                for(ll col=0; col<w; col++){
                    if(colSet.find(col)==colSet.end()) continue;
                    if(v[row][col]=='#') x++;
                }
            }
            if(x==K) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}









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

int main(){
  char b;
  cin >> b;
  if(b=='A'){
    cout << 'T' << endl;
  }
  else if(b=='T'){
    cout << 'A' << endl;
  }
  else if(b=='C'){
    cout << 'G' << endl;
  }
  else{
    cout << 'C' << endl;
  }
}

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

class Doubling:
    def __init__(self, A, K_max, decrement=True):
        """
        :param A: リスト。i から A[i] へと移動する
        :param K_max: K_max = 2**(k_max) まで参照する可能性がある
        :param decrement: True = A の要素の decrement が必要
        """
        self.k_max = K_max.bit_length()
        self.n = len(A)
        self.decrement = decrement
        self.doubling = [[-1] * self.n for _ in range(self.k_max)]
        for i, a in enumerate(A):
            self.doubling[0][i] = a - self.decrement

        for i in range(1, self.k_max):
            for j in range(self.n):
                if self.doubling[i - 1][j] == -1:
                    self.doubling[i][j] = -1
                else:
                    self.doubling[i][j] = self.doubling[i - 1][self.doubling[i - 1][j]]

    def apply(self, start, K):
        """
        :param start: スタート地点
        :param K: K回進む
        :return:
        """
        i = start - self.decrement
        for k in range(K.bit_length()):
            m = 1 << k
            if m & K:
                i = self.doubling[k][i]
            if i is None:
                break
        return i + self.decrement


######################################################################################


N, K = map(int, input().split())
A = list(map(int, input().split()))
doubling = Doubling(A, 10**18 + 1, decrement=True)
print(doubling.apply(1, K))

Measured memory_bytes: 183172
/*input
5
4
2,4
3,5
1,2
3,4
*/
fn main() {
    let mut s = format!("");
    std::io::stdin().read_line(&mut s).expect("");
    let n: u16 = s.trim().parse().expect("");
    let mut v: Vec<u16> = vec![];
    for i in 1..n + 1 {
        v.push(i);
    }
    s = format!("");
    std::io::stdin().read_line(&mut s).expect("");
    let m: u16 = s.trim().parse().expect("");
    let mut o: Vec<usize>;
    let mut temp;
    for _ in 0..m {
        s = format!("");
        std::io::stdin().read_line(&mut s).expect("");
        o = s
            .trim()
            .split(",")
            .map(|x| x.parse::<usize>().expect("") - 1)
            .collect();
        temp = v[o[0]];
        v[o[0]] = v[o[1]];
        v[o[1]] = temp;
    }
    for i in v {
        println!("{}", i);
    }
}



Measured memory_bytes: 5028
N = int(input())

W = []

ans = 0
W.append(input())

for i in range(N-1):
  Wi = input()
  WL = W[i]
  if Wi in W:
    ans = 1
    break
  if Wi[0] != WL[len(WL)-1]:
    ans = 1
    break

  W.append(Wi)

print("Yes" if ans == 0 else "No")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int main() {
	ios_base::sync_with_stdio( false );

	string S;
	cin >> S;

	string t = "CODEFESTIVAL2016";
	int ans = 0;
	for( int i = 0; i < S.size(); ++i ) {
		ans += S[i] != t[i];
	}

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


Measured memory_bytes: 256
// basically inspired by this submission: https://atcoder.jp/contests/agc026/submissions/2844908

#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
int n;
string s;
map<pair<string, string>, long long> memoo[36][36];
long long func(int l, int r, string ll, string rr){
    // while ll[0] != s[r] && rr[0] != s[l], add the current letter to the opposite string
    // while ll[0] == s[r] && rr[0] == s[l], erase them or keep going
    if (r < l){
        if (ll.size() != 0 || rr.size() != 0){
            return 0;
        }
        return 1;
    }
    //cout << l << " " << r << " " << ll << " " << rr << endl;
    auto thiss = memoo[l][r].find({ll, rr});
    if (thiss != memoo[l][r].end()){
        return thiss->second;
    }
    if (ll.size() != 0 && s[r] != ll[0]){
        return func(l, r-1, ll, rr+s[r]);
    }
    if (rr.size() != 0 && s[l] != rr[0]){
        return func(l+1, r, ll+s[l], rr);
    }
    long long res = 0;
    if (ll.size() != 0){
        res += func(l, r-1, ll.substr(1), rr);
        res += func(l, r-1, ll, rr+s[r]);
    }else if (rr.size() != 0){
        res += func(l+1, r, ll, rr.substr(1));
        res += func(l+1, r, ll+s[l], rr);
    }else{
        res += 2*func(l+1, r, ll+s[l], rr);
    }
    memoo[l][r][{ll, rr}] = res;
    return res;
}
int main(){
  prep();
  
  cin >> n >> s;
  cout << func(0, 2*n-1, "", "");
  return 0; 
}

Measured memory_bytes: 1152
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
N=int(input())
A=[int(input()) for i in range(N)]
sortA=sorted(A)
A0=[]
A1=[]
sortA0=[]
sortA1=[]
for i in range(N):
    if i%2==0:
        A0.append(A[i])
        sortA0.append(sortA[i])
    else:
        A1.append(A[i])
        sortA1.append(sortA[i])

A0=Counter(A0)
A1=Counter(A1)
sortA0=Counter(sortA0)
sortA1=Counter(sortA1)

count0=0
for a in A0:
    if a in sortA0:
        count0+=round(abs(sortA0[a]-A0[a]))
    else:
        count0+=A0[a]
print(count0)


Measured memory_bytes: 97876