akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let s: String = sc.cin();
    if s == "Sunny" {
        put!("Cloudy");
    } else if s == "Cloudy" {
        put!("Rainy");
    } else {
        put!("Sunny");
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


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


int main(){
	
	int N;
	while(cin>>N,N){
		int data[101][101]={0};
		for(int i=1,j;i<=N;i++){
			cin>>j;
			for(int k=0,l;k<j;k++){
				cin>>l;
				data[i][l]=1;
			}
		}
		
		int r;
		cin>>r;
		for(int i=0,k;i<r;i++){
			cin>>k;
			for(int j=1;j<=N;j++){
				if(data[j][k]==0)data[j][0]=1;
			}
		}
		int ans=0;
		for(int i=1;i<=N;i++){
			if(data[i][0]==0){
				if(ans==0)ans=i;
				else ans=-1;
			}
		}
		if(ans==0)ans=-1;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
// #define DEBUG 100
 
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll >;
 
const ll oo = 1e18 + 7;
const ll mod = 998244353,maxn = 1e5 + 100, maxm = 1e5+100;
const double PI = acos(-1);

int main (){
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;

    vector<ll> ps(n+1, 0), dp(n+1, 0);
    vector<pll> xs(k);

    for (auto &x: xs) cin >> x.ff >> x.ss;
    dp[1] = 1;
    ps[1] = 1;

    for (int i=2; i<=n; i++){
        for (int j=0;j<k;j++){
            int a, b, na;
            tie(a, b) = xs[j];
            na = a;
            a = max(i-b-1, 0);
            b = max(i-na, 0);
            // cout << a << " " << b << " " << ps[a] - ps[b] << endl;
            dp[i] += (ps[b] - ps[a]+mod)%mod;
            dp[i] %= mod;
        }
        ps[i] += ps[i-1] + dp[i];
        ps[i]%=mod;
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 6424
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_4_B
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
  double r;
  cin >> r;
  printf("%.6lf %.6lf\n", r*r*M_PI, 2*r*M_PI);
}

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

int main()
{
  int R0, W0, C, R;
  while(1){
    cin >> R0 >> W0 >> C >> R;
    if(R0 == 0 && W0 == 0 && C == 0 && R == 0) break;
    int ans = 0;
    while((ans++)*R+R0 < W0*C){}
    cout << ans-1 << endl;
  }
}

Measured memory_bytes: 3088
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//Wrought Gold Master
public class Main{

	public static int[] price;
	public static int[] opt;
	public static Map<String, Integer> ref;
	public static int[][] list;

	public static int get(int k){
		if(opt[k]!=Integer.MAX_VALUE){
			return opt[k];
		}
		if(list[k].length==0){
			return opt[k] = price[k];
		}
		int p = 0;
		for(int i=0;i<list[k].length;i++){
			p += get(list[k][i]);
		}
		return opt[k] = Math.min(p, price[k]);
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			price = new int[300];
			opt = new int[300];
			list = new int[300][0];
			Arrays.fill(opt, Integer.MAX_VALUE);
			int id = 0;
			ref = new HashMap<String, Integer>();
			for(int i=0;i<n;i++){
				ref.put(sc.next(), id);
				price[id++] = sc.nextInt();
			}
			int m = sc.nextInt();
			while(m--!=0){
				String s = sc.next();
				if(!ref.containsKey(s)){
					ref.put(s, id++);
				}
				int i = ref.get(s);
				int k = sc.nextInt();
				list[i] = new int[k];
				for(int j=0;j<k;j++){
					s = sc.next();
					if(!ref.containsKey(s)){
						ref.put(s, id++);
					}
					list[i][j] = ref.get(s);
				}
			}
			System.out.println(get(ref.get(sc.next())));
		}
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
int main(void)
{
	int i,cnt;
	char s[3],t[3];
	scanf("%s %s",s,t);
	cnt=0;
	for(i=0;i<3;i++){
		if(s[i]==t[i]){
			cnt++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
    #define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    #include <algorithm>
    #include <bits/stdc++.h>
    #define MOD 1000000007
    #define ll long long
    #define mm(arr) memset(arr, 1, sizeof(arr))
    #define scanArray(a,n) for(ll i = 0; i < n; i++){cin >> a[i];}
    using namespace std;

    int main(){
        FAST
        string s; cin >> s;
        
        int j=0;
         vector<string> days= {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

        for(int i=0; i<7; i++){
            if(days[i] == s){
                j=i;
            }
        }
        cout << 7-j << endl;


        return 0;
    }


Measured memory_bytes: 3548
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"
)

func main() {
	solve(os.Stdin, os.Stdout)
}

func solve(in io.Reader, out io.Writer) {
	var bs = NewBufScanner(in)
	var bw = NewBufWriter(out)
	defer bw.w.Flush()

	line := strings.Split(bs.Scan(), " ")
	s := strings.Join(line, "")
	f, _ := strconv.ParseFloat(s, 64)
	sq := math.Sqrt(f)

	ans := ""
	if math.Floor(sq) == sq {
		ans = "Yes"
	} else {
		ans = "No"
	}

	bw.Printf("%s\n", ans)
}

// BufScanner original scanner
type BufScanner struct {
	s *bufio.Scanner
}

// NewBufScanner constructer
func NewBufScanner(in io.Reader) *BufScanner {
	s := bufio.NewScanner(in)
	return &BufScanner{
		s: s,
	}
}

// Scan Scan Data
func (b *BufScanner) Scan() string {
	b.s.Scan()
	return b.s.Text()
}

// BufWriter original writer
type BufWriter struct {
	w *bufio.Writer
}

// NewBufWriter constructer
func NewBufWriter(out io.Writer) *BufWriter {
	w := bufio.NewWriter(out)
	return &BufWriter{
		w: w,
	}
}

// Printf Output file
func (b *BufWriter) Printf(format string, a ...interface{}) {
	fmt.Fprintf(b.w, format, a...)
}

Measured memory_bytes: 640
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  int *h = new int[n];
  int *dp = new int[n];
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    dp[i] = 0;
  }

  dp[1] = abs(h[0] - h[1]);
  for (int i = 2; i < n; i++) {
    dp[i] =
        (dp[i - 1] + abs(h[i] - h[i - 1])) < (dp[i - 2] + abs(h[i] - h[i - 2]))
            ? (dp[i - 1] + abs(h[i] - h[i - 1]))
            : (dp[i - 2] + abs(h[i] - h[i - 2]));
  }

  cout << dp[n - 1] << endl;
  delete[] h;
  delete[] dp;
  return 0;
}


Measured memory_bytes: 1024
from collections import Counter as C
n = int(input())
v = [int(a) for a in input().split()]

a=C(v[::2])
b=C(v[1::2])
a[0]=b[0]=0
a=a.most_common()
b=b.most_common()
if a[0][0] != b[0][0]:
    print (n-a[0][1]-b[0][1])
else:
    print (min(n-a[1][1]-b[0][1],n-a[0][1]-b[1][1]))


Measured memory_bytes: 18656
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ld in;
    cin>>in;
    ll x = (in+1)/2;
    cout(10)<<x/in<<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  long A, B, K, tmp;
  cin >> A;
  cin >> B;
  cin >> K;

  if(K >= A) {
    K -= A;
    A = 0;
  } else {
    A -= K;
    K = 0;
  }

  if(K >= B) {
    B = 0;
  } else {
    B -= K;
  }

  cout << A << " " << B;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,A;
    cin>>N;
    vector<int> V(N);
    for(int i=0;i<N;i++){
   cin>>V.at(i);
    }
    sort(V.begin(),V.end());
    reverse(V.begin(),V.end());
    int L=0;
    int B=0;
    for(int i=0;i<N;i++){
      if(i%2==0){
        L+=V.at(i);
      }
      else{
        B+=V.at(i);
      }
    }
    cout<<L-B<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#define INF 1000000000
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long int ll;
using namespace std;

int main() {

	int n, l; cin >> n >> l;
	int sum = 0;
	int ans = INF;
	for (int i = 1; i <= n; i++) {
		sum += i + l - 1;
		if (abs(ans) > abs(i + l - 1)) {
			ans = i + l - 1;
		}
	}
	//cout << sum << " " << ans << endl;
	cout << sum - ans << endl;

	return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main(){
    int n;
    cin >> n;
    vector<ll>l(n);
    rep(i, 0, n)cin >> l[i];
    int ans = 0;
    rep(i, 0, n){
        rep(j, i+1, n){
            rep(k, j+1, n){
                bool flag1=false,flag2 = false;
                if(l[i]+l[j]>l[k]&&l[i]+l[k]>l[j]&&l[j]+l[k]>l[i])flag1 = true;
                if(l[i]!=l[j]&&l[i]!=l[k]&&l[j]!=l[k])flag2 = true;
                if(flag1&&flag2)ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>

using namespace std;

string print(string s, int a, int b){
    string ret;
    ret.resize(b-a+1);
    for(int i=0; i<=b-a;i++){
        ret[i]=s[i+a];
    }
    return ret;
}

string replace(string s, int a, int b, string p){
    string ret=s;
    for(int i=0; i<=b-a;i++)
        ret[i+a]=p[i];
    return ret;
}

string reverse(string s, int a, int b){
    string ret=s;
    for(int i=a; i<=b;i++)
        ret[i]=s[b-i+a];
    return ret;
}

int main(){
    
    string s, o,p;
    int q,a,b;
    cin >>s >>q;
 
    for(int i=0;i<q;i++){
        cin >> o >>a>>b;

        if(o=="print"){
            cout << print(s,a,b)<<endl;
        }
        else if(o=="replace"){
            cin >> p;
            s=replace(s,a,b,p);
            //cout <<s<<endl;
        }else if(o=="reverse"){
            s=reverse(s,a,b);
            //cout <<s<<endl;
        }
        else
            cout <<"err"<<endl;
    }
    return 0;
} 


Measured memory_bytes: 3212
n = int(input())
a = list(map(int, input().split()))
INF = 10**9
mod = a[::]
previous_min = min(a)

while True:
    if sum(mod) == 0:
        ans = previous_min
        break
    current_min = min(filter(lambda x: x > 0, mod))
    mod = [a[i] % current_min for i in range(len(a))]
    previous_min = current_min

print(ans)

Measured memory_bytes: 15020
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    bool oddA = A % 2 == 1;
    bool oddB = B % 2 == 1;
    bool oddC = C % 2 == 1;
    int ans = 0;
    if (!(oddA == oddB && oddB == oddC)) {
        if (oddA == oddB) {
            A++;
            B++;
        }
        else if (oddB == oddC) {
            B++;
            C++;
        }
        else {
            C++;
            A++;
        }
        ans++;
    }
    int x = max({ A,B,C });
    ans += (x + x + x - A - B - C) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<float.h>
#include<string.h>
 
#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)	/* rep */
#define scin(a) scanf("%d",&a);
#define scdo(a) scanf("%lf",&a);
#define scch(a) scanf("%s",a);
#define anin(a) printf("%d\n",a);
#define ando(a) printf("%lf\n",a);
#define anch(a) printf("%s\n",a);

 
int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}
 
int main(void){
	long long int A,B,C,D,ans,x,r;
	scanf("%lld %lld %lld %lld",&A,&B,&C,&D);
	ans = (B / C) - ((A - 1) / C);
	ans += (B / D) - ((A - 1) / D);
	x = D * C;		
	r = D % C;
	while(r!=0){
    	D = C;
    	C = r;
    	r = D % C;
  	}
	r = x / C;
	ans -= (B / r) - ((A - 1) / r);
	ans = B - A + 1 - ans;
	printf("%lld\n",ans);				
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#define MOD 1000000007
using namespace std;

int main() {
  long long N; cin >> N;
  long long ans = 1;
  for (int i = 0; i < N; i++) ans = (ans * 10) % MOD;
  long long ans_ = 1;
  for (int i = 0; i < N; i++) ans_ = (ans_ * 8) % MOD;
  long long ans_2 = 1;
  for (int i = 0; i < N; i++) ans_2 = (ans_2 * 9) % MOD;
  ans = ((ans - (2 * ans_2 - ans_)) % MOD + MOD) % MOD;
  cout << ans << endl;
}

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

int main() {
  vector<int> A = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int x, y;
  cin >> x >> y;
  if (A.at(x) == A.at(y)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
m,d=map(int,input().split())
count=0
for i in range(m):
    i=i+1
    for j in range(d):
        j=j+1
        d_10=j//10
        d_01=j-d_10*10
        if d_10>=2 and d_01>=2 and d_10*d_01==i:
            count +=1
print(count)

Measured memory_bytes: 39408
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc113_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();

            WriteLine(input[0]+input[1]/2);
            //WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);
            //WriteLine($"答えは{input[0]+input[1]}");
        }
    }
}

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

string f(ll n) {
    if (n == 0) return "";
    n--;
    return f(n/26) + string(1, 'a'+n%26);
}
int main() {
    ll n;
    cin >> n;

    cout << f(n) << endl;
}

Measured memory_bytes: 3632
a, b, h, m = STDIN.readline.chomp.split.map(&:to_f)
h = Math::PI * 2.0 * (h / 12.0 + m / 720.0)
m = Math::PI * 2.0 * m / 60.0
puts Math::sqrt(((a * Math::cos(h) - b * Math::cos(m)) ** 2.0 + (a * Math::sin(h) - b * Math::sin(m)) ** 2.0))


Measured memory_bytes: 14792
#include <stdio.h>
#include <string.h>
int main(){
int n;
scanf("%d", &n);
int beki[]={1000,961,900,841,784,729,676,625,576,529,512,484,441,400,361,343,324,289,256,243,225,216,196,169,144,128,125,121,100,81,64,49,36,32,27,25,16,9,8,4,1};
for(int i=0;;i++){
if(beki[i]<=n){
printf("%d\n", beki[i]);return 0;
}
}
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#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() {
  char c;
  cin >> c;
  cout << (char)(int)(c+1) << endl;
  return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

int main()
{
    int a, b, C;
    cin >> a >> b >> C;
    double S, L, h;
    double C_rad = C*M_PI/180.0;
    S = a*b*sin(C_rad)/2.0;
    double c = sqrt(a*a + b*b - 2*a*b*cos(C_rad));
    L = a + b + c;
    h = 2*S / a;
    printf("%.5lf %.5lf %.5lf\n", S, L, h);
}


Measured memory_bytes: 3372
n=int(input(""))
ain=input("").split(" ")
a={1:0,}
c=[]
for i in range(n):
    c+=[int(ain[i])]
s=sum(c)
for i in range(n):
    if (c[i] in a):
        a[c[i]]+=1
    else:
        a[c[i]]=1
q=int(input(""))
c=[]

for i in range(q):
    c=input("").split(" ")
    bb=int(c[0])
    cc=int(c[1])
    if (bb in a and a[bb]!=0):
        s+=(cc-bb)*a[bb]
        if (cc in a):
            a[cc]+=a[bb]
        else:
            a[cc]=a[bb]
        a[bb]=0
                              
    print(s)
    
    
    


Measured memory_bytes: 24208
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                continue 
            if l[i] + l[j] > l[k] and l[j] + l[k] > l[i] and l[k] + l[i] > l[j]:
                cnt += 1
print(cnt)

Measured memory_bytes: 9084
#include <bits/stdc++.h>
#define full(c) c.begin(), c.end()
typedef signed long long int ll;
typedef unsigned long long int ull;
using namespace std;

int main(){
  while(1){
    bool end=false;
    int i,n;
    map<int, int> cnt;
    cin>>n;
    if(n==0) break;
    for(i=0; i<n; i++){
      int a;
      cin>>a;
      cnt[a]++;
      if(cnt[a] > n/2){
        cout<<a<<endl;
        end=true;
        break;
      }
      if(end==true) break;
    }
    if(end == true){
      i++;
      while(i < n){
        int a;
        cin>>a;
        i++;
      }
      continue;
    }
    cout<<"NO COLOR"<<endl;
  }
  return 0;
}


Measured memory_bytes: 4596
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
##############################


def main():
    S = input().rstrip()
    zero = S.count("0")
    one = S.count("1")

    print ( min(zero, one) * 2 )

main()


Measured memory_bytes: 3188
#!usr/bin/env python3
import sys
input = lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(10 ** 8)
def solve():
    n = int(input())
    while n != 0:
        w = tuple(map(int, input().split()))
        dp = [[0] * (n + 1) for _ in range(n + 1)]
        for i in range(n - 1, -1, -1):
            for j in range(i + 1, n):
                if (j - i + 1) % 2 == 0:
                    if dp[i + 1][j - 1] == j - i - 1 and abs(w[i] - w[j]) <= 1:
                        dp[i][j] = dp[i + 1][j - 1] + 2
                    else:
                        p = tuple(dp[i][k] + dp[k + 1][j] for k in range(i, j + 1))
                        dp[i][j] = max(p)
                else:
                    dp[i][j] = max(dp[i][j - 1], dp[i + 1][j])
        print(dp[0][n - 1])
        n = int(input())


if __name__ == "__main__":
    solve()



Measured memory_bytes: 9312
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

#include <stack>
typedef long long ll;
typedef unsigned long long ull;

// size, top, pop, push, empty

int main() {

	stack<string> st;
	string str;

	while (cin >> str) {

		if (str == "+"){
			ll i2 = stoll(st.top()); st.pop();
			ll i1 = stoll(st.top()); st.pop();
			st.push(to_string(i1 + i2));
		}
		else if (str == "-"){
			ll i2 = stoll(st.top()); st.pop();
			ll i1 = stoll(st.top()); st.pop();
			st.push(to_string(i1 - i2));
		}
		else if (str == "*"){
			ll i2 = stoll(st.top()); st.pop();
			ll i1 = stoll(st.top()); st.pop();
			st.push(to_string(i1 * i2));
		}
		else{
			st.push(str);
		}
	}

	cout << st.top() << endl;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int X, Y;
  cin >> X >> Y;
  if (X*4 < Y || X*2 > Y) {
    cout << "No" << endl;
  } else if (Y % 2 == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
import sys
import re
import queue
import collections
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []


def main():
	N,K= i_map()
	m = 998244353
	L = []
	R = []
	for i in range(0,K):
		tmpL,tmpR = i_map()
		L.append(tmpL)
		R.append(tmpR)

	a = []
	a.append(0)
	a.append(-1)
	for i in range(2,3*N):
		a.append(0)

	f = []
	f.append(1)

	for i in range(0,N):
		for j in range(0,K):
			a[i+L[j]] += f[i]
			a[i+R[j]+1] += -f[i]
		f.append((f[i]+a[i+1])%m)

	print(f[N-1]%m)

	return

if __name__ == '__main__':
	main()

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

long long N;

vector<pair<long long, long long> >leftvec;
vector<pair<long long, long long> >rightvec;

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++) {
		string s;
		cin >> s;
		long long mini = 0;
		long long cur = 0;
		for(long long j = 0; j < s.size(); j++) {
			if(s[j] == ')') {
				cur--;
			} else {
				cur++;
			}
			mini = min(mini, cur);
		}
		if( cur>= 0) {
			leftvec.push_back(make_pair(mini, cur));
		} else {
			rightvec.push_back(make_pair(mini - cur, -1 * cur));
		}
	}


	sort(leftvec.begin(), leftvec.end(), greater<pair<long long, long long> >());
	sort(rightvec.begin(), rightvec.end(), greater<pair<long long, long long> >());

	long long cur = 0;
	for(long long i = 0; i < leftvec.size(); i++) {
		if(cur + leftvec[i].first < 0) {
			cout << "No" << endl;
			return 0;
		}
		cur += leftvec[i].second;
	}

	long long rightcur = 0;
	for(long long i = 0; i < rightvec.size(); i++) {
		if(rightcur + rightvec[i].first < 0) {
			cout << "No" << endl;
			return 0;
		}
		rightcur += rightvec[i].second;
	}

	if(rightcur == cur) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 19084
import sys

input = sys.stdin.readline


def main():
    A, B, C = map(int, input().split())

    cnt_5 = 0
    for i in [A, B, C]:
        if i == 5:
            cnt_5 += 1

    cnt_7 = 0
    for i in [A, B, C]:
        if i == 7:
            cnt_7 += 1

    if cnt_5 == 2 and cnt_7 == 1:
        print("YES")
    else:
        print("NO")


if __name__ == "__main__":
    main()


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

int main(){
  int N,M;
  cin >>N>>M;
  vector <int> a(N,1);
  vector <int> b(N,0);
  b[0]=1;
  int x,y;     
  
  //cout<<a[0]<<a[1]<<a[2]<<endl;
  //cout<<b[0]<<b[1]<<b[2]<<endl;
            
  
  for (int i=0;i<M;i++){
    cin>>x>>y;
    if(b[x-1]==1){
      b[y-1]=1;
    }
    a[x-1]--;
    if(a[x-1]==0){
      b[x-1]=0;
    }
    a[y-1]++;
  //cout<<"#"<<endl;
  //cout<<a[0]<<a[1]<<a[2]<<a[3]<<endl;
  //cout<<b[0]<<b[1]<<b[2]<<b[3]<<endl;
  }
  int cnt=0;
  for (int i=0;i<N;i++){
    //cout<<a[i]<<" "<<b[i]<<" "<<i<<endl;
    if((a[i]>0)&&(b[i]==1)){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
    int a,b,k,flag=0;
    scanf("%d",&k);
    scanf("%d %d",&a,&b);
    for(int i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            flag=1;
            break;
        }
    }
    if(flag)
    printf("OK");
    else
    printf("NG");
}

Measured memory_bytes: 1736
using System;

namespace abc167_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string noAddData = Console.ReadLine();
            string addData = Console.ReadLine();
            string addDataHantei = addData.Substring(0, noAddData.Length);

            if (noAddData.Equals(addDataHantei))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 25820
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
int dp[60][2];
int dfs(vector< int > &A, int k, int tight) {
	if (dp[k][tight] > 0)
		return dp[k][tight];
	if (k < 0)
		return 0;
	int one = 0, zero = 0;
	rep(i, N) {
		if ((A[i] >> k) & 1) {
			++one;
		} else {
			++zero;
		}
	}
	int x = (tight == 1 ? ((K >> k) & 1) : 1);
	int ret = 0;
	for (int i = 0; i <= x; i++) {
		int t;
		if (!tight) {
			t = 0;
		} else if (i == x) {
			t = 1;
		} else {
			t = 0;
		}
		chmax(ret, dfs(A, k - 1, t) + (!i ? one : zero) * (1LL << k));
	}
	return dp[k][tight] = ret;
}
signed main() {
	cin >> N >> K;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	int ans = dfs(A, 59, 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
from collections import deque

def id(i, j):
    return v_id[min(i, j)][max(i, j)]

def TopologicalSort(graph, in_deg, N):
    sorted_v = []
    q = deque()

    for i in range(N):
        if in_deg[i] == 0:
            q.append(i)
    
    while q:
        v = q.popleft()
        for n_v in graph[v]:
            in_deg[n_v] -= 1
            if in_deg[n_v] == 0:
                q.append(n_v)
        
        sorted_v.append(v)

    if len(sorted_v) == N:
        return sorted_v
    else:
        return 0

N = int(input())
v_id = [[-1]*N for _ in range(N)]
graph = [[] for _ in range(N * (N - 1) // 2)]
in_deg = [0]*(N * (N - 1) // 2)

v = 0
for i in range(N):
    for j in range(N):
        if i < j:
            v_id[i][j] = v
            v += 1

for i in range(N):
    a = list(map(lambda x: int(x) - 1, input().split()))
    for j in range(N - 2):
        graph[id(i, a[j])].append(id(i, a[j + 1]))
        in_deg[id(i, a[j + 1])] += 1

sorted_v = TopologicalSort(graph, in_deg, N * (N - 1) // 2)

if not sorted_v:
    print(-1)
else:
    dist = [0]*(N * (N - 1) // 2)

    for v in sorted_v:
        for n_v in graph[v]:
            dist[n_v] = max(dist[n_v], dist[v] + 1)
    
    print(max(dist) + 1)

Measured memory_bytes: 169736
#abc165c
import itertools
n,m,q=map(int,input().split())
l=list(itertools.combinations_with_replacement(range(1,m+1),n))
res=[0]*len(l)
for i in range(q):
 a,b,c,d=map(int,input().split())
 for j,x in enumerate(l):
  if x[b-1]-x[a-1]==c:
   res[j]+=d
print(max(res))


Measured memory_bytes: 25168
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextInt()
	b := nextInt()
	c := nextInt()
	//入れ替え操作
	a, b = b, a
	a, c = c, a
	fmt.Println(a, b, c)
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#ifdef LOCAL
#define debug(x)   cerr<<#x<<" = "<<x<<endl
#else
#define debug(x) 
#endif
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define pii pair<int,int>
#define endl '\n'
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
const int inf = 1e18 + 5;
signed main()
{
  #ifdef LOCAL
      input_from_file;
      output_to_file;
    #endif 
    IOS
    int n,k; cin>>n>>k;
    int h[n];
    int ans= 0;
    for(int i=0;i<n;i++)
    {
      cin>>h[i];
      if(h[i] >= k) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
for i in range(N):
	line = input()
	l = [None]*3
	l[0] = int(line.split()[0])
	l[1] = int(line.split()[1])
	l[2] = int(line.split()[2])
	l.sort()
	if l[0]**2+l[1]**2==l[2]**2:
		print("YES")
	else:
		print("NO")

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

using namespace std;

const int N=1e6+3;

const double eps=0.000000001;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9;

int n,m,a[N],b[N],k,q,u,x,y,tc,c,l,r,ans;

char s[N];

void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

string ss;

vector<string> v;

void solve(int idx,int cnt){
	if (idx>=n){
		v.push_back(ss);
		return;
	}
	for(int i=0;i<=cnt;i++){
        ss+='a'+i;
	    solve(idx+1,cnt+(i==cnt));
        ss.pop_back();
	}
}

int main(){
	//IO();
	scanf("%d",&n);
	solve(0,0);
    sort(v.begin(),v.end());
    for(auto &x:v)
        printf("%s\n",x.c_str());
}



Measured memory_bytes: 9588
use std::io::stdin;
use std::str::FromStr;

fn main(){
    let n: usize = get_one();
    let xs: Vec<i64> = get_vec();
    let ys: Vec<i64> = get_vec();

    if xs.iter().fold(0, |acc, x| acc+x) < ys.iter().fold(0, |acc, x| acc+x) {
        println!("-1");
    } else {
        let mut rem = Vec::new();
        let mut short = Vec::new();
        for i in 0..n {
            if xs[i] < ys[i] {
                short.push(ys[i] - xs[i]);
            } else {
                rem.push(xs[i] - ys[i]);
            }
        }
        if short.len() == 0 { println!("0") }
        else {
            rem.sort();
            rem.reverse();
            let mut short_sum = short.iter().fold(0, |acc, x| acc+x);
            for (i, &r) in rem.iter().enumerate() {
                short_sum -= r;
                if short_sum <= 0 {
                    println!("{}", i+1+short.len());
                    break;
                }
            }
        }
    }
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}


Measured memory_bytes: 11512
#include <iostream> // cout, endl, cin
#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
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int N,M;
vector<vector<int>> G;
vector<int> dist;
bool all = false;

void dfs(int v,int p=-1){
    for(int nv: G[v]){
        if(nv == p) continue;
        if(dist[nv] == -1){
            dist[nv] = 1^dist[v];
            dfs(nv);
        }else{
            if(dist[nv] == dist[v]){
                all = true;
            }
        }
    }
};
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> M;
    G = vector<vector<int>> (N);
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        a--;b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    dist = vector<int> (N,-1);
    dist[0] = 0;
    dfs(0);
    if(all){
        cout << (ll)N*(N-1)/2 - M << "\n";
    }else{
        int cnt = 0;
        for(int i=0; i<N; i++){
            if(dist[i]) cnt++;
        }
        cout << (ll)cnt*(N-cnt) - M << "\n";
    }
    return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,w,h) rep(j,h)rep(i,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> a(n);rep(i,n)std::cin >> a[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
    ll n;
    std::cin >> n;
    std::cout << n*(n-1)/2 << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector> 
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
using namespace std;

int main(){
  string a,b;
  a="ARC";
  b="ABC";
  string S;
  cin>>S;
  if(S==a){
    cout<<b;
    }
  else{
    cout<<a;
  }

}

Measured memory_bytes: 3624
I, O, T, J, L, S, Z = map(int, input().split())
res = O
res += sum(map(lambda x: x//2*2, [I, J, L]))
res += 3*min(map(lambda x: x%2, [I, J, L]))

res2 = O
if I and J and L:
    res2 += 3
    I, J, L = map(lambda x: x-1, [I, J, L])

res2 += sum(map(lambda x: x//2*2, [I, J, L]))
print(max(res, res2))

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,ans;
int main(){
	ll a,b,aa[100]={};
	scanf("%lld%lld%lld",&n,&a,&b);
	rep(i,0,n){
		ll t;
		scanf("%lld",&t);
		if(t<=a)aa[0]++;
		else if(t>b)aa[2]++;
		else aa[1]++;
	}
	printf("%lld\n",min(aa[0],min(aa[1],aa[2])));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;
const int N = 100000;

int n;
vector<int> G[N];

// ??°??£????????????????????????/??????
pi dp1[N];
void dfs(int v, int par)
{
    int res = 0;
    for(int nx:G[v])if(nx!=par)
    {
        dfs(nx,v);
        res += dp1[nx].fi+2;
    }

    int notback = res;
    for(int nx:G[v])if(nx!=par)
    {
        int t = res;
        t -= dp1[nx].fi+2;
        t += dp1[nx].se+1;
        notback = min(notback,t);
    }

    dp1[v] = {res,notback};
}

int ans[N];
void dfs2(int v, int par, pi d)
{

    // v????????¨???????????????????????¨????????¨?????¨????????±?????????
    vector<pair<pi,int>> c;
    // ???????????????
    for(int nx:G[v])if(nx!=par) c.pb({dp1[nx],nx});
    // ?????????
    c.pb({d,-1});

    int C = c.size();
    // ??¨??¨?????¨?????¨???????????????????????£?????°??£?????????????????¨???????????´???????????????
    int sum = 0;
    rep(i,C) sum += c[i].fi.fi+2;

    // second????????¶?????¨????????£?????????????????????(?°?????????????????¬???????)
    // (??????,??????)
    vector<pi> gain;

    // ??????v??????????????????????¨??????????
    ans[v] = sum;
    // ????????¨?????¨???"??°?????????"??????????????¨??¢?´¢
    rep(i,C)
    {
        // "??°??£?????????"??????"??°?????????"???????????????????????¨????????£????????????????????????
        int g = c[i].fi.se+1 - (c[i].fi.fi+2);

        ans[v] = min(ans[v],sum+g);
        gain.pb({g,c[i].se});
    }

    // ??????????????¨?????¨????????± d ?????´??°????????????????????????????????????
    sort(all(gain));
    rep(i,C)
    {
        int nx = gain[i].se;
        if(nx==-1) continue;

        pi nd;
        // "??°??£?????????"???????????????????????¨?????¨?????¶??????????????°??????
        nd.fi = sum - (dp1[nx].fi+2);

        // "??°?????????"???????????????????????¨?????¨??????????????????????????????????????§???????????§??´?????\?±????????????????
        // ??????????????????????????¨?????¨???"??°?????????"??????????????§????????????????????§?¬??????§????????¨?????????"??°?????????"??????????????????
        // ????????§???????????°??????????????¨?????¨???"??°?????????"???????????°??????
        nd.se = nd.fi;
        if(i==0)
        {
            if(C>1) nd.se += gain[1].fi;
        }
        else nd.se += gain[0].fi;

        dfs2(nx,v,nd);
    }
}

int main()
{
    cin >>n;
    rep(i,n-1)
    {
        int u,v;
        cin >>u >>v;
        --u;
        --v;
        G[u].pb(v);
        G[v].pb(u);
    }

    dfs(0,-1);
    dfs2(0,-1,{-2,-1});
    rep(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 31632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (x + 1 <= b - a) {
			System.out.println("dangerous");
		} else if (0 >= b - a) {
			System.out.println("delicious");
		} else {
			System.out.println("safe");
		}

		sc.close();

	}

}

Measured memory_bytes: 35604
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define MAX_N 50
int N,M;

vector<string> A(MAX_N,"");
vector<string> B(MAX_N,"");

bool check(int x,int y){
    int X,Y;
    //座標(x,y)から探索する。
        for(Y = 0; Y < M; Y++){
            for(X = 0; X < M; X++){
                if(B[Y][X] != A[y+Y][x+X]){
                    return false;
                }
            }
        }
        return true;
}

int main(){
    cin >> N >> M;
    for(int d = 0; d < N; d++) cin >> A[d];
    for(int d = 0; d < M; d++) cin >> B[d];
    bool is_find = false;

    for(int y = 0; y < N - M + 1; y++){
        for(int x = 0; x < N - M + 1; x++){
            if(check(x,y)==true){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    if(is_find) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s; i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;


int main(){
    int n; cin >> n;
    string s; cin >> s;
    int l = s.length();
    vector<int> t(l);
    REP(i, l){
        t[i] = s[i] - 'A';
        t[i] = (t[i] + n) % 26;
        s[i] = t[i] + 'A';
    }
    cout << s << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  vl a(3);
  rep(i, 3) {
    cin >> a[i];
  }
  sort(all(a));
  if (a[0] == a[1] and a[1] == a[2] or
      a[0] != a[1] and a[1] != a[2]) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
/* created   : 2019-09-10 22:43:07
 * accepted  : 2019-09-10 23:10:31
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int n, k; cin >> n >> k;
  string s; cin >> s;
  int ans = 0;
  for (int i = 0; i + 1 < n; i++) {
    if (s[i] == 'L' && s[i + 1] == 'L') {
      ans++;
    }
  }
  for (int i = 1; i < n; i++) {
    if (s[i] == 'R' && s[i - 1] == 'R') {
      ans++;
    }
  }
  cout << min(n - 1, ans + 2 * k) << '\n';
}

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


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;
int main(void){
    // Your code here!
    int n;
    std::cin >> n;
    int a[100];
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    sort(a,a+n);
    std::cout << a[n-1]-a[0] << std::endl;
}


Measured memory_bytes: 256