akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
  map<int, int> mp;
  for (int i = 0; i < N; i++)
    mp[a[i]]++;
  int ans = 0;
  for (auto a : mp)
  {
    if (a.first < a.second)
      ans += a.second - a.first;
    else if (a.second < a.first)
      ans += a.second;
  }
  cout << ans << endl;
  return 0;
}

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

int main(void)
{
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        A[i] = a;
        B[i] = b;
    }

    set<int> transits;
    int trA = 0, trB = 0;
    for(int i =0 ; i < M; i++){
        if(A[i] == 1) {
            transits.insert(B[i]);
            trA++;
        }
        if(B[i] == N) {
            transits.insert(A[i]);
            trB++;
        }
    }

    if(transits.size() == (trA+trB)){
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << "POSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 13936
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	string st;
	cin >> st;
	cout << string(st.size(), 'x') << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
    int T, X;
    cin >> T >> X;

    cout << fixed << setprecision(10) << (double) T/X << endl;

}



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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(long long i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9


int main(){
  int A, B;
  cin >> A>> B;
  cout << (A+B) % 24 << endl;
  return 0;
}


Measured memory_bytes: 256
N = input()
nums = list(map(int, input().split()))

sorted_nums = sorted(nums, reverse=True)

a = 0
b = 0

def calSumOfDig(n):
    total = 0
    for i in n:
        total += i
    return total


ls = calSumOfDig(sorted_nums[0::2]) - calSumOfDig(sorted_nums[1::2])

print(ls)

Measured memory_bytes: 3064
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

a,b,x = I()
 
if (a**2*b)<=2*x:
    c = 2*(a**2*b-x)/a**3
else:
    c = (a*b**2)/(2*x)
 
print(math.degrees(math.atan(c)))

Measured memory_bytes: 10612
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#define rep(a,b,c) for(ll a=b;a<=c;a++)
#define per(a,b,c) for(ll a=b;a>=c;a--)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 5;
const int M = 2e5 + 5;
int n, k;
int a[N];
int cnt, b[N];
int c[N];

int main(){
    int sum = 0;
    cin >> n >> k;
    rep(i,1,n) cin >> a[i], sum += a[i];
    sort(a+1,a+1+n);
    for(int i = 1; i * i <= sum; i ++){
        if(sum % i == 0){
            b[++cnt] = i;
            if(sum / i != i) b[++cnt] = sum / i;
        }
    }
    sort(b+1,b+1+cnt);
    priority_queue<int> que;
    for(int i = cnt; i >= 1;i--){
        int mx = b[i], res = 0;
        rep(j,1,n){
            int tmp = a[j] % mx;
            tmp = mx - tmp;
            que.push(tmp);
            res += tmp;
        }
        while(res){
            que.pop();
            res -= mx;
        }
        int p = 0;
        while(!que.empty()) p += que.top(), que.pop();
        if(p <= k){
            printf("%d\n", mx);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
        putchar('x');
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll n; cin >> n;
  cout << 48-n << endl;
}

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

int main() {
    int h, w, k;
    char mp[10][10];
    cin >> h >> w >> k;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> mp[i][j];
        }
    }


    int ans = 0;
    for (int x = 0; x < (1 << h); x++) {
        for (int y = 0; y < (1 << w); y++) {
            bitset<10> s(x);
            bitset<10> t(y);

            int cnt = 0;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (s[i] && t[j] && mp[i][j] == '#') cnt++;
                }
            }

            if (cnt == k) ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Numerics;
using System.Diagnostics;

class Program
{
    static int f(int a)
    {
        if((a & 1 ) == 0)
            return a / 2;
        else
            return 3 * a + 1;
    }
    public void Slove()
    {
        int s = int.Parse(Console.ReadLine());
        List<int> array = new List<int>(){s };
        foreach(int i in Enumerable.Range(2, 1000000))
        {
            int a = f(array[array.Count - 1]);
            //Console.WriteLine(a);
            if(array.Contains(a))
            {
                Console.WriteLine(i);
                break;
            }
            array.Add(a);
        }
    }
    static void Main(string[] args)
    {
        var p = new Program();
        p.Slove();
    }
}


Measured memory_bytes: 13268
import collection.mutable.ArrayBuffer
import scala.reflect.ClassTag
import scala.language.implicitConversions

trait Graph { 
    case class Edge[T:Numeric](from : Int, to : Int, cost : T)

    class Edges[T:Numeric](val data : ArrayBuffer[Edge[T]]) {
        def size = data.size
    }
    object Edges {
        def apply[T:Numeric](xs : Edge[T]*) = new Edges(ArrayBuffer(xs:_*))
        implicit def toUnderLying[T](x:Edges[T]) = x.data
    }

    class WeightedGraph[T:Numeric](val size : Int, val data : Array[Edges[T]]) {
        def this(size : Int) = this(size, Array.fill(size)(Edges()))
    }
    object WeightedGraph {
        // def apply[T:Numeric](size : Int) = new WeightedGraph[T](size)
        implicit def toUnderLying[T](x:WeightedGraph[T]) = x.data
    }

    class UnWeightedGraph[T:Numeric](val size : Int, val data: Array[ArrayBuffer[T]]) {
        def this(size : Int) = this(size, Array.fill(size)(ArrayBuffer[T]()))
    }
    object UnWeightedGraph {
        // def apply[T:Numeric](size : Int) = new UnWeightedGraph[T](size)
        implicit def toUnderLying[T](x:UnWeightedGraph[T]) = x.data
    }
   
    class Matrix[T:Numeric:ClassTag](val row : Int, val col : Int, val data : Array[Array[T]]) {
        def this(row : Int, col : Int) = this(row, col, Array.fill(row, col)(implicitly[Numeric[T]].zero))
        def this(size : Int) = this(size, size)
    }
    object Matrix {
        implicit def toUnderLying[T](x:Matrix[T]) = x.data
    }
}

object BellmanFord extends Graph {
    import Edges._

    // return ArrayBuffer() when find a negative cycle
    def bellmanFord(edges : Edges[Int], V : Int, s : Int, INF : Int) : Array[Int] = {
        val dist = Array.fill(V)(INF)
        dist(s) = 0
        for (_ <- 1 until V) {
            for (e <- edges) {
                if(dist(e.from) != INF) 
                    dist(e.to) = dist(e.to) min (dist(e.from) + e.cost)
            }
        }
        // check a negative cycle
        for (e <- edges) {
            if(dist(e.from) != INF) 
                if ((dist(e.from) + e.cost) < dist(e.to))
                    return Array.empty
        }
        dist
    }
}

import BellmanFord._

object Main {
    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val V, E, r = sc.nextInt
        val edges = Edges[Int]()
        for (_ <- 1 to E) {
            val s, t, c = sc.nextInt
            edges += Edge(s, t, c)
        }
        val res = bellmanFord(edges, V, r, Int.MaxValue)
        if (res.isEmpty) println("NEGATIVE CYCLE")
        else {
            for (d <- res)
            if (d == Int.MaxValue) println("INF")
            else println(d)
        }
    }
}


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

typedef long long int ll;

#define endl '\n'


int main()
{

    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n,L;
    cin>>n>>L;

    vector <ll> vec;
    ll su = 0;
    for(ll i=1;i<=n;i++){
        vec.push_back(L+i-1);
        su+=L+i-1;
    }
    ll diff = INT_MAX;
    ll ans = 0;
    for(ll i=0;i<n;i++){
        if(abs(su-(su-vec[i])) < diff ){
            diff = abs(su-(su-vec[i]));
            ans = su-vec[i];
        }
    }
    cout<<ans<<endl;


}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
        int n,i=0;
        long int k;
        char s[101];
        scanf("%s %d",s,&k);
        while(s[i]=='1') i++;
        if(s[i]==NULL) printf("1\n");
        else if((i>=k)&&(i!=0)) printf("1\n");
        else printf("%c\n",s[i]);
        return 0;
}


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

vector<string> parse(string line)
{
  auto tokens = vector<string>{};
  auto delimiter = " ";
  auto tokenPos = line.find(delimiter);
  auto lastTokenPos = -1;

  while (tokenPos != std::string::npos)
  {
    auto token = line.substr(lastTokenPos + 1, tokenPos - lastTokenPos - 1);
    tokens.push_back(token);

    lastTokenPos = tokenPos;
    tokenPos = line.find(delimiter, tokenPos + 1);
  }

  auto token = line.substr(lastTokenPos + 1, line.length() - lastTokenPos - 1);
  tokens.push_back(token);

  return tokens;
}

bool is_operator(string op)
{
  return op == "+" || op == "-" || op == "*";
}

int operate(string op, int first, int second)
{
  if (op == "+")
  {
    return second + first;
  }
  else if (op == "-")
  {
    return second - first;
  }
  else
  {
    return second * first;
  }
}

int main()
{
  string line;
  getline(cin, line);
  auto tokens = parse(line);

  auto s = stack<string>{};
  auto ops = stack<string>{};
  for (auto token : tokens)
  {
    s.push(token);
  }

  while (!s.empty())
  {
    auto current = s.top();
    s.pop();

    if (is_operator(current))
    {
      ops.push(current);
      continue;
    }

    // opsに演算子があるとき
    if (!ops.empty() && is_operator(ops.top()))
    {
      // stackの先頭が数字のとき
      if (!s.empty() && !is_operator(s.top()))
      {
        auto ops_top = ops.top();
        auto s_top = s.top();

        ops.pop();
        s.pop();
        s.push(to_string(operate(ops_top, stoi(current), stoi(s_top))));
        continue;
      }

      // stackの先頭がopのとき
      if (!s.empty() && is_operator(s.top()))
      {
        auto s_top = s.top();
        s.pop();

        ops.push(current);
        ops.push(s_top);
        continue;
      }
    }

    // opsに直前に数字, 更にその前に演算子と入っているとき.
    if (!ops.empty() && !is_operator(ops.top()))
    {
      auto ops_top = ops.top();
      ops.pop();
      auto ops_second = ops.top();
      ops.pop();
      s.push(to_string(operate(ops_second, stoi(ops_top), stoi(current))));
      continue;
    }

    // この分岐に来るのは最後のときだけ.
    cout << current << endl;
  }

  return 0;
}



Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
int n,m;
long long s[3010],t[3010],dp[3010][3010];
signed main(){
	cin>>n>>m;
	rep(i,n)cin>>s[i];
	rep(i,m)cin>>t[i];
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i-1]==t[j-1]){
				dp[i][j]=1+dp[i][j-1]+dp[i-1][j];
			}
			else{
				dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
			}
			dp[i][j]=(dp[i][j]+MOD)%MOD;
		}
	}
	cout<<(dp[n][m]+1)%MOD<<endl;
	return 0;
}


Measured memory_bytes: 46976
N = int(input())
c0,c1,c2,c3 = 0,0,0,0

for i in range(N):
    a = input()
    if a == "AC":
        c0 += 1
    elif a =="WA":
        c1 +=1
    elif a == "TLE":
        c2 += 1
    elif a == "RE":
        c3 += 1

print("AC x %d" %c0)
print("WA x %d" %c1)
print("TLE x %d" %c2)
print("RE x %d" %c3)
    

Measured memory_bytes: 9196
import bisect
n = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))
ans = 0
for i in range(n):
    b = B[i]
    a = bisect.bisect_left(A, b)
    c = n-bisect.bisect_right(C, b)
    ans += a*c
print(ans)


Measured memory_bytes: 23232
let cnt = ref 0

let merge a l m r =
  let ni = m - l in
  let nj = r - m in
  let init_ary n p =
    Array.init (n + 1) (fun i -> if i = n then max_int else a.(p + i))
  in
  let ai = init_ary ni l in
  let aj = init_ary nj m in
  let rec doit i j k =
    if k >= r then ()
    else begin
      incr cnt;
      if ai.(i) <= aj.(j) then (a.(k) <- ai.(i); doit (i + 1) j (k + 1))
      else (a.(k) <- aj.(j); doit i (j + 1) (k + 1))
    end
  in
  doit 0 0 l

let rec merge_sort a l r =
  if (l + 1) < r then begin
    let m = (l + r) / 2 in
    merge_sort a l m;
    merge_sort a m r;
    merge a l m r
  end

let () =
  let n = read_int () in
  let a = Array.of_list (List.map int_of_string (Str.split (Str.regexp " ") (read_line ()))) in
  merge_sort a 0 n;
  Array.iteri (fun i e -> Printf.printf (if i = 0 then "%d" else " %d") e) a;
  print_newline ();
  Printf.printf "%d\n" !cnt

Measured memory_bytes: 78000
#include<bits/stdc++.h>
#define MAX 100001
int main()
{
	int n, q;
	std::cin >> n >> q;
	char s[MAX];
	std::cin >> s;
	int a[MAX], b[MAX], c[MAX];
	for (int i = 0; i < q; i++)
		std::cin >> a[i] >> b[i];
	c[0] = 0;
	for (int i = 1; i < n; i++)
		if (s[i] == 'C'&&s[i - 1] == 'A')
			c[i] = c[i - 1] + 1;
		else
			c[i] = c[i - 1];
	for (int i = 0; i < q; i++)
		std::cout << c[b[i]-1] - c[a[i]-1] << std::endl;
	return 0;
}

Measured memory_bytes: 2048
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <stdio.h>
#include <bits/stdc++.h>

#define uint unsigned int
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;
using namespace std;
const int N = 2 * 1e3 + 10;
int tot , a[N] , n , x; 
string s;
stack < char > st;
main(){
	
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> s;
	for(int i = 0 ; i < sz(s) ; i++){
		if(st.empty())
			st.push(s[i]);
		else if(s[i] == 'S')
			st.push('S');
		else {
			if(st.top() == 'S')
				st.pop();
			else 
				st.push('T');
		}
	}
	cout << sz(st) ;
  }

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
typedef vector<int> vi;

int main() {
  int N;
  int t[110000], x[110000], y[110000];
  cin >> N;
  t[0] = x[0] = y[0] = 0;
  rep(i, N) cin >> t[i+1] >> x[i+1] >> y[i+1];

  bool can = true;
  rep(i, N) {
    int dt = t[i+1] - t[i];
    int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if (dt < dist) can = false;
    if (dist % 2 != dt % 2) can = false;
  }

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

  return 0;
}

Measured memory_bytes: 4696
#include <iostream>
#include <string>
#include <map>
#define MCI map<char,int>
using namespace std;
int main()
{
  MCI m;
  m.insert(MCI::value_type('I',1));
  m.insert(MCI::value_type('V',5));
  m.insert(MCI::value_type('X',10));
  m.insert(MCI::value_type('L',50));
  m.insert(MCI::value_type('C',100));
  m.insert(MCI::value_type('D',500));
  m.insert(MCI::value_type('M',1000));

  string s;
  while(cin >> s){
    int l = s.length();
    char p = s[0];
    int n=0;
    for(int i=1;i<l;i++){
      char c = s[i];
      if(m[p] < m[c]) n -= m[p];
      else n += m[p];
      p = c;
    }
    n += m[p];
    cout << n << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int d[]= {sc.nextInt(),sc.nextInt(),sc.nextInt()};
        sort(d);
        String ans="Yes";
        if(d[0]!=d[2])ans="No";

        out.println(ans);
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

class P implements Comparable<P>{
    int id,T;
    P(int id, int T) {
        this.id=id;
        this.T=T;
    }
    public int compareTo(P p){
        return id-p.id; //des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long[] nextLongArray(int size) throws IOException{
    	long r[] = new long[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextLong(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

typedef long long ll;
typedef int64_t i6;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define Sort(x) sort(x.begin(), x.end())
#define Sort_rev(x) sort(x.begin(), x.end(), greater<int>())
#define ALL(v) (v).begin(), (v).end()

//π M_PI
//deg = rad*180/M_PI

int main() {
    int m1, m2, d1, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if ( m1+1 == m2 ) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


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

int main(){
    int N; cin >> N;
    map<int,int> map;
    for(int i=0;i<N;i++){
        int a; cin >> a;
        map[a]++;
    }
    int cnt=0;
    int ans=0;
    for(auto it=map.begin();it!=map.end();it++){
        if(it->second>1){
            if(it->second%2==0){
                it->second=2;
            }else{
                it->second=1;
            }
        }
        if(it->second==2) cnt++;
        if(it->second==1) ans++;
    }
    if(cnt%2==0){
        cout << ans+cnt << endl;
    }else{
        cout << ans+cnt-1 << endl;
    }

}

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

int main(){
  int n,d; cin >> n >> d;
  vector<vector<int>> arr (n,vector<int>(d));
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      cin >> arr[i][j];
    }
  }
  int cnt = 0;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < i; j++){
        int sum = 0;
          for(int k = 0; k < d; k++){
            int s = arr[i][k]-arr[j][k];
            sum += s*s;
          }
          int s = sqrt(sum)+0.5;
          if(s*s == sum) cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

#define ll long long

#define ull unsigned long long

#define pii pair<int, int>

#define pll pair<ll int, ll int>

#define ff first

#define ss second

#define pb push_back

#define eb emplace_back

#define debug(n) cout << "DEBUG1 " << n << "\n";

#define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n";

#define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n";

#define debug4(n, m, x, y) cout << "DEBUG4 " << n << ' ' << m << ' ' << x << ' ' << y << "\n";

#define ss_def stringstream ss // stringstream, do ss_def(str), then ss >> n (n is int)

#define upzero(n) if (n < 0) n = 0

#define alive(n) cout << "Alive here: checkpoint " << n << endl

#pragma GCC optimize("Ofast")

using namespace std;

void yes() {

 cout << "YES\n";

 return;

}

void no() {

 cout << "NO\n";

 return;

}

const ll int MOD = 998244353, mxN = 2e5 + 1;

vector<pii> v;

ll int dp[mxN], ps[mxN];

void init() {

 // initialize

 

}

void solve(int case_no) {

 // implementation

 int n,k;

 cin >> n >> k;

 for (int i=0;i<k;i++) {

     int x,y;

     cin>>x>>y;

     v.eb(x,y);

 }

    dp[0]=0;

    dp[1]=1;

    ps[1]=1;

    for(int i=2;i<=n;i++) {

        for (pii p : v) {

            dp[i] += ps[max(0,i-p.ff)] - ps[max(0,i-p.ss-1)];

            dp[i]%=MOD;

        }

        ps[i]=ps[i-1]+dp[i];

        ps[i]%=MOD;

    }

    while (dp[n]<0) dp[n]+=MOD;

    cout << dp[n] << endl;

}

int main() {

    ios::sync_with_stdio(false);

    cin.tie(NULL);

    cout.tie(NULL);

    srand(time(NULL));

    init();

    int t = 1;

//    cin >> t;

    for (int i = 1;i <= t;i++) solve(i);

}

/*

*/

Measured memory_bytes: 6764
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int a,b,x;
  cin>>a>>b>>x;
  Int ans=1e15;
  for(Int i=0;i<=5000;i++)
    for(Int j=0;j<=5000;j++)
      if(i*1000+j*500>=x) chmin(ans,i*a+j*b);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3100
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if(A < B){
        if(A + V*T >= B + W*T){
            cout << "YES";
        }else{
            cout << "NO";
        }
    }else{
        if(A - V*T <= B - W*T){
            cout << "YES";
        }else{
            cout << "NO";
        }
    }
}

Measured memory_bytes: 3644
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		System.out.println("a " + (a < b ? "<" : (a == b ? "==" : ">")) + " b");
	}
}



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

#define F first 
#define S second
#define PB push_back
#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, k;
int nxt[N], c[N];

int main()
{
    cin >> n >> k;
    for (int i = 1; i <= n; i ++ ) cin >> nxt[i];
    for (int i = 1; i <= n; i ++ ) cin >> c[i];

    LL res = -1e18;
    for (int i = 1; i <= n; i ++ )
    {
        int cycle_cnt = 0, v = i;
        LL cycle_sum = 0;
        while (true)
        {
            cycle_cnt ++ ;
            cycle_sum += c[v];
            v = nxt[v];
            if (v == i) break;
        }

        int cnt = 0;
        LL sum = 0;
        v = i;
        while (true)
        {
            cnt ++ ;
            sum += c[v];
            if (cnt > k) break;
            
            int num = (k - cnt) / cycle_cnt;
            LL t = sum + max(0LL, cycle_sum) * num;
            res = max(res, t);

            v = nxt[v];
            if (v == i) break;
        }
    }
    cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <queue>

using namespace std;

queue<pair<int, pair<int, int>>> que;

int main() {
    int H, W;
    int A[1000][1000];

    cin >> H >> W;

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            char a;
            cin >> a;
            A[i][j] = a == '#';
        }
    }

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

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if(A[i][j] == 1) {
                que.push({1, {i, j}});
            }
        }
    }

    int depth = 1;

    while(que.size()) {
        auto p = que.front(); que.pop();
        depth = p.first;

        for(int k = 0; k < 4; k++){
            int next_w = p.second.second + dx[k];
            int next_h = p.second.first + dy[k];

            if(next_w >= 0 && next_h >= 0 && next_w < W && next_h < H && A[next_h][next_w] == 0) {
                A[next_h][next_w] = depth+1;
                que.push({depth+1, {next_h, next_w}});
            }
        }
    }

    cout << depth - 1 << endl;
}


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

int gcd(int a,int b){
	int c;
	if(a<b){
		a+=b;b=a-b;a-=b;
	}
	while(b!=0){
		c=a%b;
		a=b;
		b=c;
	}
	return a;
}

int main(){
	int a,b;
	while(cin>>a>>b)
		cout<<gcd(a,b)<<endl;
	return 0;
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
A,B = map(int,input().split())
if A != 1 and B != 1:
  if A > B:
    print("Alice")
  elif A == B:
    print("Draw")
  else:
    print("Bob")
    
else:
  if A > B:
    print("Bob")
  elif A == B:
    print("Draw")
  else:
    print("Alice")


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

ll n,k,a[5005],c[5005],c2[5005],m=1e9+7;

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

cin>>n>>k;
rep(i,0,n-1)cin>>a[i],c[a[i]]++;
ll ans=0,k2=(k*(k-1))/2;
k2%=m;
rep(i,0,n-1)
{
	c2[a[i]]++;
	ll cc2=0,cc1=0;
	rep(j,a[i]+1,3004)cc2+=c2[j];
	rep(j,a[i]+1,3004)cc1+=c[j];
	cc1%=m;
	cc2%=m;
	ans=(ans+(k*cc2))%m;
	ans=(ans+(k2*cc1))%m;
}
ol(ans);
return 0;
}



Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Text;


namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            //??\?????????????????????????????????
            string[] s = Console.ReadLine().Split(' ');
            //????????±???a?????\??????
            int a = int.Parse(s[0]);
            //????????±???b????????????
            int b = int.Parse(s[1]);
            //??¢??????a*b
            int area = a * b;
            //??¨??????(a+b)*2
            int rect = (a + b) * 2;

            Console.WriteLine(area + " " + rect);


        }
    }
}

Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priotity_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ld PI=abs(acos(-1));
int n,m,k,a,b,c,d,e;
string s,t,w;

int main(){
	cin >> a >> b >> c;
	
	cout << (a-c)/(b+c) << endl;
	return 0;
}


Measured memory_bytes: 256
A,B,H,M = map(int,input().split())
minu = H * 60 + M

kaku1 = 360 *minu / (12*60)
kaku2 = 360 *minu / 60
kaku = max(abs(kaku1-kaku2),abs(kaku2-kaku1))

import math

cos = math.cos(math.radians(kaku))
print((A**2+B**2 - 2*A*B*cos)**(1/2))


Measured memory_bytes: 9504
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define MAXM 200001
#define MAXN 100001
#define INF 100000000

using namespace std;

typedef long long int int64;

typedef struct
{
	vector<int64> dest;
	vector<int64> route;
	int64 cost;
	int64 index;
} node;

typedef struct
{
	bool operator()(const node* a,const node* b)//operator<
	{
		return a->cost > b->cost;
	}
} cmp_pnode;

typedef struct
{
	int64 dist;
	int64 count;//0-
	int64 sum;
} dst;

int64 N,M,C,A[MAXM],B[MAXM],D[MAXM];
node S[MAXN];
vector<node*> R;
bool E[MAXN];
priority_queue<node*,vector<node*>,cmp_pnode> prc;

signed main(void)
{
	for(int64 i = 0;i < MAXN;i++)
	{
		S[i].cost = INF;
		S[i].index = i;
		E[i] = false;
	}
	cin >> N >> M >> C;
	for(int64 i = 0;i < M;i++)
	{
		cin >> A[i] >> B[i] >> D[i];
		A[i]--;
		B[i]--;
		S[A[i]].dest.push_back(B[i]);
		S[A[i]].route.push_back(D[i]);
		S[B[i]].dest.push_back(A[i]);
		S[B[i]].route.push_back(D[i]);
	}
	S[0].cost = 0;
	prc.push(&S[0]);
	node* tp;
	while(!prc.empty())
	{
		tp = prc.top();
		prc.pop();
		for(int64 i = 0;i < tp->dest.size();i++)
		{
			if(S[tp->dest[i]].cost > tp->cost + tp->route[i])
			{
				S[tp->dest[i]].cost = tp->cost + tp->route[i];
				prc.push(&S[tp->dest[i]]);
			}
		}
	}
	for(int64 i = 0;i < N;i++)
	{
		R.push_back(&S[i]);
	}
	sort(R.begin(),R.end(),[](const node* a,const node* b){return a->cost < b->cost;});
	int64 sum = 0;
	for(int64 i = 0;i < M;i++)
	{
		sum = sum + D[i];
	}
	int64 mincost = sum;
	for(auto itr = R.begin();itr != R.end();itr++)
	{
		E[(*itr)->index] = true;
		for(int64 i = 0;i < (*itr)->dest.size();i++)
		{
			if(E[(*itr)->dest[i]])
			{
				sum -= (*itr)->route[i];
			}
		}
		mincost = min(mincost,sum + (C * (*itr)->cost));
	}
	cout << mincost << endl;
}

Measured memory_bytes: 27716
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

constexpr int MAX = 55;
constexpr int MAX_S = 850;
constexpr int INF = (1 << 20);

void update(int& l, int r)
{
    if (l > r) l = r;
}

int dp[MAX][MAX_S][MAX_S];

int main()
{
    int N, sum = 0;
    cin >> N;
    vector<int> T(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i];
        sum += T[i];
    }

    sort(T.begin(), T.end());    

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j < MAX_S; j++) {
            for (int k = 0; k < MAX_S; k++) {
                dp[i][j][k] = INF;
            }
        }
    }
    
    dp[0][0][0] = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < MAX_S - T[i]; j++) {
            for (int k = 0; k < MAX_S - T[i]; k++) {
                update(dp[i + 1][j + T[i]][k], dp[i][j][k] + 1);
                update(dp[i + 1][j][k + T[i]], dp[i][j][k] + 1);
                update(dp[i + 1][j][k], dp[i][j][k] + 1);
            }
        }
    }

    int res = INF;
    for (int i = 0; i < MAX_S; i++) {
        for (int j = 0; j < MAX_S; j++) {
            if (dp[N][i][j] != INF) {
                res = min(res, max(i, max(j, sum - i - j)));
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 147092
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define first fi
#define second se
#define MOD 1000000007
#define MAXN 1000006
#define endl "\n"
#define readln(x) getline(cin, x);
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
ll fpow(ll x, ll n, ll mod){if (n==0) return 1%mod; ll u = fpow(x, n/2, mod); u = (u*u)%mod; if (n%2==1)u = (u*x)%mod;return u;}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

string s;
int q;
vector<char> e[2];
bool rev = false;
int main(){
    //freopen("data.txt","r",stdin);
    cin >> s >> q;
    while(q--){
        int t; cin >> t;
        if (t == 1){
            if (!rev) rev = true;
            else rev = false;
        }
        else{
            int f; char c; cin >> f >> c;
            if (f == 1){
                if (rev){
                    e[1].pb(c);
                }
                else e[0].pb(c);
            }
            else{
                if (rev){
                    e[0].pb(c);
                }
                else e[1].pb(c);
            }

        }
    }
    string sta = "";
    for (int i = (int)e[0].size() - 1; i >= 0; --i){
        sta += e[0][i];
    }
    string en = "";
    for (auto c : e[1]){
        en += c;
    }
    s += en;
    sta += s;
    if (rev) reverse(sta.begin(), sta.end());
    cout << sta << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;

int main(){
   int n,res=0; cin>>n;
  ll h[n]; REP(i,n)cin>>h[i];
  ll v[n]; v[n-1]=0;
  
   for(int i=n-1;i>=1;i--){
    if(h[i]<=h[i-1])v[i-1]=v[i]+1;
     else v[i-1]=0;
     if(v[i-1]>=res)res=v[i-1];
   }
   cout<<res<<endl;
}



Measured memory_bytes: 1792
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr=sorted(arr,key=lambda x:x[0])
ans=1
r=arr[0][0]+arr[0][1]
for i in range(1,n):
  l=arr[i][0]-arr[i][1]
  if r<=l:
    ans+=1
    r=arr[i][0]+arr[i][1]
  else:
    r=min(r,arr[i][0]+arr[i][1])
print(ans)

Measured memory_bytes: 29864
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        GetAC solver = new GetAC();
        solver.solve(1, in, out);
        out.close();
    }

    static class GetAC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int q = in.nextInt();
            char[] s = in.next().toCharArray();
            int[] dp = new int[n];

            for (int i = 0; i < n - 1; i++) {
                if (s[i] == 'A' && s[i + 1] == 'C') {
                    dp[i + 1] = dp[i] + 1;
                } else {
                    dp[i + 1] = dp[i];
                }
            }

            for (int i = 0; i < q; i++) {
                int l = in.nextInt() - 1;
                int r = in.nextInt() - 1;
                out.println(dp[r] - dp[l]);
            }

        }

    }
}



Measured memory_bytes: 63236
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int N;cin>>N;
    cout<<"ABC"<<N<<endl;
}

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

#define MAX_N 100000
#define MAX_M 100000
#define MAX 1000000007

int N, M;
long long ans;

int main(){
    cin >> N >> M;
    if(N == M){
        ans = 1;
        for(int i = 1; i <= N; ++i){
            ans *= i;
            ans %= MAX;
        }
        ans = (ans * ans * 2) % MAX;
    }else if(abs(N - M) == 1){
        ans = 1;
        for(int i = 1; i <= N; ++i){
            ans *= i;
            ans %= MAX;
        }
        for (int i = 1; i <=M; ++i){
            ans *= i;
            ans %= MAX;
        }
    }else{
        cout << 0 << "\n";
        return 0;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
using namespace std;

int main()
{
	
	
	int t;
	scanf("%d",&t);
	for(int i=0;i<t;i++){
		string a;
		string b;

		cin >> a;
		cin >> b;	
		string res;
		reverse(a.begin(),a.end());
		reverse(b.begin(),b.end());
		int carry = 0;
		int idx;
		for(int j=0;j<min(a.size(),b.size());j++){
			int lhs = a[j] - '0';
			int rhs = b[j] - '0';
			res.push_back((carry + lhs + rhs) % 10 + '0');
			carry = (carry + lhs + rhs) / 10 ? 1 : 0;
			idx =j;
		}

		for(int j=idx+1;j<max(a.size(),b.size());j++){
			if(a.size() > b.size()){
				int lhs = a[j] - '0';
				res.push_back((carry + lhs) % 10 + '0');
				carry = (carry + lhs) / 10 ? 1 : 0;
			}
			else{
				int rhs = b[j] - '0';
				res.push_back((carry + rhs) % 10 + '0');
				carry = (carry + rhs) / 10 ? 1 : 0;
			}
		}
		if(carry) res.push_back(carry+'0');
		reverse(res.begin(),res.end());
		res = (res.size() > 80) ? "overflow" : res;
		cout << res << endl;
	}	
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 21;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n;
string s;
ll ans = 0;
int main(){
  cin >> n >> s;
  for(ll i = 0;i < n;i++){
    if(s[i] == 'R') ans++;
    else ans--;
  }
  if(ans > 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N,M;
    cin>>N>>M;
    vector<int> p(M);
    vector<string> S(M);
    rep(i,M){
        cin>>p[i]>>S[i];
    }
    int ACcnt=0,WAcnt=0;
    set<int> SP;
    rep(i,M){
        if(SP.count(p[i]-1)){
            
        }else{
            if(S[i]=="WA"){
                WAcnt++;
            }else{
                ACcnt++;
                SP.insert(p[i]-1);
            }
        }
    }
    //ACして無いのにWAした分を引く
    rep(i,M){
        if(!SP.count(p[i]-1)&&S[i]=="WA"){
            WAcnt--;
        }
    }
    cout << ACcnt << " " << WAcnt<<endl;
    return 0;

}

Measured memory_bytes: 10752
from collections import Counter

N = int(input())
C = [Counter(input()) for _ in range(N)]
# print(f'{C=}')

word_set = set(C[0].keys())
for c in C:
    word_set &= set(list(c.keys()))
# print(f'{word_set=}')

W = {key: 10**8 for key in word_set}
for c in C:
    for word in word_set:
        W[word] = min(W.get(word, 0), c.get(word, 0))
# print(f'{W=}')

ans = ''
for key, value in W.items():
    ans += key * value
# print(f'{ans=}')
print(''.join(sorted(ans)))


Measured memory_bytes: 9332
#include <iostream>
using namespace std;
int main(){
  string a;
  cin >> a;
  if(a=="A"){
    cout << "T";
  }else if(a=="C"){
    cout << "G";
  }else if(a=="G"){
    cout << "C";
  }else{
    cout << "A";
  }
  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;

const int INF = 1e9 + 5;

int main() {
	int n;
	scanf("%d", &n);
	
	vector<int> dp(3);
	for (int day = 0; day < n; ++day){
		vector<int> new_dp(3, 0);
		vector<int> c(3);
		for (int i = 0; i<3; ++i){
			scanf("%d", &c[i]);
		}
		
		for (int i = 0; i < 3; ++i){
			for(int j=0; j<3; ++j){
				if ( i != j) {
					new_dp[j] = max(new_dp[j], dp[i] + c[j]);
				}
			}
		}
		dp = new_dp;
	}
	printf("%d\n", max({dp[0], dp[1], dp[2]}));
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <math.h>
int main(void){
	int n,s[1000],i;
	double ex1,ex2,b;
	while(scanf("%d",&n),n){
                ex1=ex2=0;
		for(i=0;i<n;i++){
			scanf("%d",&s[i]);
			ex1+=s[i]*s[i];
			ex2+=s[i];
		}
		b=sqrt((ex1/n)-pow(ex2/n,2));
		printf("%.8f\n",b);
	}
	return 0;
}

Measured memory_bytes: 640
from collections import Counter
from heapq import heapify, heappop, heappush
from itertools import groupby

n = int(input())
aaa = list(map(int, input().split()))
bbb = list(map(int, input().split()))

idx_a = {}
cnt_a = {}
i = 0
for a, itr in groupby(aaa):
    cnt = len(list(itr))
    idx_a[a] = i
    cnt_a[a] = cnt
    i += cnt

cnt_b = Counter(bbb)
hq_both = []
hq_free = []
for a, ca in cnt_a.items():
    if a in cnt_b:
        hq_both.append((-(ca + cnt_b[a]), a))
    else:
        hq_free.append(a)
heapify(hq_both)

# Aの個数とBの個数の和が大きいやつがヤバげ

ans = [-1] * n
remaining = n

while hq_both:
    cab, a1 = heappop(hq_both)
    cab = -cab
    assert cab == cnt_a[a1] + cnt_b[a1]

    # print(a1, cab, cnt_a, cnt_b, ans, hq_both, hq_free)

    if cab > remaining:
        print('No')
        exit()

    cb = cnt_b[a1]
    while cb:
        if hq_both:
            _, a2 = heappop(hq_both)
            pop_from_que = True
        else:
            a2 = hq_free.pop()
            pop_from_que = False
        ca = cnt_a[a2]
        # print('b', cb, a2, pop_from_que, ca <= cb, hq_both, hq_free)
        if ca <= cb:
            l = idx_a[a2]
            ans[l:l + ca] = [a1] * ca
            remaining -= ca
            idx_a[a2] += ca
            cnt_a[a2] -= ca
            cnt_b[a1] -= ca
            cb -= ca
        else:
            l = idx_a[a2]
            ans[l:l + cb] = [a1] * cb
            remaining -= cb
            idx_a[a2] += cb
            cnt_a[a2] -= cb
            cnt_b[a1] -= cb
            cb = 0
            if pop_from_que:
                heappush(hq_both, (-(cnt_a[a2] + cnt_b[a2]), a2))
            else:
                hq_free.append(a2)
        # print('b', cb, a2, pop_from_que, ca <= cb, hq_both, hq_free)
    hq_free.append(a1)

for b, cb in cnt_b.items():
    if cb == 0:
        continue
    while cb:
        a = hq_free.pop()
        ca = cnt_a[a]
        if ca <= cb:
            l = idx_a[a]
            ans[l:l + ca] = [b] * ca
            cb -= ca
        else:
            l = idx_a[a]
            ans[l:l + cb] = [b] * cb
            idx_a[a] += cb
            cnt_a[a] -= cb
            cb = 0
            hq_free.append(a)

print('Yes')
print(*ans)


Measured memory_bytes: 85208
#include <bits/stdc++.h>
using namespace std;
int main(){

  string A;
  string B;
  cin >> A >> B;
  if(A[0] == B[2] && A[1] == B[1] && A[2] == B[0])cout << "YES" << endl;
  else cout << "NO" << endl;


  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 100000
#define mp make_pair
#define X first
#define Y second
#define pb push_back
int n;
int dsum[N+1],sz[N+1];
vector<int> nei[N+1];
int dfs(int x=1,int dep=0,int fa=0){
//	cout<<x<<" visiting\n";
	int res=dep;
	for(int i=0;i<nei[x].size();i++){
		int y=nei[x][i];
		if(y!=fa)res+=dfs(y,dep+1,x);
	}
	return res;
}
pair<int,int> pc[N+1];int oid[N+1];
vector<pair<int,int> > ans;
signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",dsum+i),pc[i]=mp(dsum[i],i);
	sort(dsum+1,dsum+n+1);sort(pc+1,pc+n+1);
	for(int i=1;i<=n;i++)oid[i]=pc[i].Y;
	fill(sz+1,sz+n+1,1);
	for(int i=n;i>=2;i--){
		int fadsum=dsum[i]+2*sz[i]-n;
		int fd=lower_bound(dsum+1,dsum+i,fadsum)-dsum;
		if(dsum[fd]!=fadsum)return puts("-1"),0;
		sz[fd]+=sz[i];
		ans.pb(mp(fd,i));
		nei[fd].pb(i);nei[i].pb(fd);
	}
//	for(int i=1;i<=n;i++){for(int j=0;j<nei[i].size();j++)cout<<nei[i][j]<<" ";puts("");}
	if(dfs()!=dsum[1])return puts("-1"),0;
	for(int i=0;i<ans.size();i++)printf("%lld %lld\n",oid[ans[i].X],oid[ans[i].Y]);
	return 0;
}

/*1
7
10
15
13
18
11
14
19
*/
/*2
2
1
2
*/
/*3
15
57
62
47
45
42
74
90
75
54
50
66
63
77
87
51
*/

Measured memory_bytes: 16240