akhauriyash/Code-Regression huggingface dataset:
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n  # 各要素の親要素の番号を格納するリスト

    def find(self, x):  # 要素xが属するグループの根を返す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):  # 要素xが属するグループと要素yが属するグループとを併合する
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):  # 要素xが属するグループのサイズ（要素数）を返す
        return -self.parents[self.find(x)]

    def same(self, x, y):  # 要素x, yが同じグループに属するかどうかを返す
        return self.find(x) == self.find(y)

    def members(self, x):  # 要素xが属するグループに属する要素をリストで返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):  # すべての根の要素をリストで返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):  # グループの数を返す
        return len(self.roots())

    def all_group_members(self):  # {ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, Q = map(int, input().split())
uf = UnionFind(N)
ans = []
for _ in range(Q):
    com, x, y = map(int, input().split())
    if com:
        if uf.same(x, y):
            ans.append(1)
        else:
            ans.append(0)
    else:
        uf.union(x, y)
print(*ans, sep='\n')



Measured memory_bytes: 7244
import math 

arr = input().split()
a = int(arr[0])
b = int(arr[1])
x = int(arr[2])
if b*a*a > x:
    ans1 = 90-math.atan(a*a*a/(2.0*(b*a*a-x)))/math.acos(-1)*180
else:
    ans1 = 0.0
ans2 = math.atan(a*b*b/2/x)/math.acos(-1)*180

if a*a*b/2 <= x:
    print (ans1)
else:
    print (ans2)

Measured memory_bytes: 3064
n = int(input())
h = list(map(int, input().split()))
counter = 0
maximum = 0

for i in range(1, n):
  num = h[i]
  if num <= h[i-1]:
    counter += 1
    if maximum <= counter:
      maximum = counter
  else:
    counter = 0


print(maximum)

Measured memory_bytes: 63984
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
using namespace std ;

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e18
#define endl "\n"

ll power(ll b,ll e,ll m)
{
	if(e==0)
		return 1;
	if(e%2)
		return b*power(b*b%m,(e-1)/2,m)%m;
	else
		return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0)
		return 1;
	if(e%2)
		return b*power(b*b,(e-1)/2);
	else
		return power(b*b,e/2);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,i;
	cin>>n;
	ll a[n];
	for(i=0;i<n;i++)cin>>a[i];
	ll ans=1;
	ll mini=a[0];
	for(i=1;i<n;i++)
	{
		if(a[i]<mini)
			{
				++ans;
				mini=a[i];
			}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int h, w;
	cin >> h >> w;
	if (h % 3 == 0 || w % 3 == 0) {
		print(0);
		return 0;
	}
	int ret = INF;
	rep1(i, h) {
		int s1 = i * w;
		int s2 = (h - i)*(w / 2);
		int s3 = (h - i)*w - s2;
		int s4 = (h - i) / 2 * w;
		int s5 = (h - i)*w - s4;
		ret = min(ret, max({ s1, s2, s3 }) - min({ s1, s2, s3 }));
		ret = min(ret, max({ s1, s4, s5 }) - min({ s1, s4, s5 }));
	}
	swap(h, w);
	rep1(i, h) {
		int s1 = i * w;
		int s2 = (h - i)*(w / 2);
		int s3 = (h - i)*w - s2;
		int s4 = (h - i) / 2 * w;
		int s5 = (h - i)*w - s4;
		ret = min(ret, max({ s1, s2, s3 }) - min({ s1, s2, s3 }));
		ret = min(ret, max({ s1, s4, s5 }) - min({ s1, s4, s5 }));
	}
	print(ret);
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[][] A = new int[2+1][N+1];
    for (int i = 1; i <= 2; i++) {
      for (int j = 1; j <= N; j++) {
        int a = sc.nextInt();
        A[i][j] = a + Math.max(A[i-1][j], A[i][j-1]);
      }
    }
    
    System.out.println(A[2][N]);
  }
}

Measured memory_bytes: 22612
# -*- coding: utf-8 -*-

import math

while True:
  try:
    ( a, b, c, d, e, f ) = map ( float, input ( ).split ( ) )
  except EOFError: break
  x = ( c * e - b * f ) / ( a * e - b * d )
  y = ( a * f - c * d ) / ( a * e - b * d )
  print ( "%.3f %.3f" % ( round ( x * 1e3 ) / 1e3, round ( y * 1e3 ) / 1e3 ) )

Measured memory_bytes: 6828
#include <stdio.h>

void euc(int, int);

int main(void) {
  int a, b;
  while(1) {
    scanf("%d %d", &a, &b);
    if (a == 0 && b == 0)
      break;
    euc(a, b);
  }
  return 0;
}

void euc(int a, int b){
  int c = 0, r = 1, tmp;
  if(a < b) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while(1) {
    r = a % b;
    c++;
    if (r == 0)
      break;
    else {
      a = b;
      b = r;
    }
  }
  printf("%d %d\n", b, c);
}



Measured memory_bytes: 2044
import java.util.*

open class MainKt {
    companion object Static {
        @JvmStatic fun main(args: Array<String> = arrayOf()) {
            MainKt().solve()
        }
    }

    val scanner = Scanner(System.`in`)

    fun printf(pattern: String, vararg args: Any): Unit {
        println(String.format(pattern, *args))
    }

    open fun println(line: String) {
        kotlin.io.println(line)
    }

    fun println(line: Int) {
        println(line.toString())
    }

    fun println(line: Long) {
        println(line.toString())
    }

    open fun readLine(): String {
        return scanner.nextLine()
    }

    fun readArg(): String {
        return readLine()
    }

    fun readInt(): Int {
        return readArg().toInt()
    }

    fun readLong(): Long {
        return readArg().toLong()
    }

    fun readIntList(): List<Int> {
        return readArgList().map { it.toInt() }
    }

    fun readLongList(): List<Long> {
        return readArgList().map { it.toLong() }
    }

    fun readArgList(): List<String> {
        return readLine().split(" ")
    }

    fun solve() {
        val n = readInt()
        val bList = mutableListOf<Int>()
        for (i in 1..n) {
            bList.add(readInt())
        }
        var bId = 0
        for (i in 0..(n - 1)) {
            bId = bList[bId] - 1
            if (bId == 1) {
                println(i + 1)
                return
            }
        }
        println(-1)
    }
}

Measured memory_bytes: 113720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;cin >> n;
  ll k;cin >> k;
  vector<ll> c(100005);
  for(int i=0;i<n;i++){
    int a,b;cin >> a >> b;
    c[a]+=b;
  }
  ll sum=0;
  for(int i=1;i<100005;i++){
    sum+=c[i];
    if(sum>=k){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
mint nibeki(ll m){
  if(m == 0) return 1;
  auto t = nibeki(m / 2);
  t = t * t;
  if(m & 1) t = t * 2;
  return t;
}
mint com(ll n, ll k){
  mint re = 1;
  _rep(i, 1, k + 1) re = re * mint(n - i + 1) / mint(i);
  return re;
}

int main(){
  ll n, a, b; cin >> n >> a >> b;
  cout << nibeki(n) - 1 - com(n, a) - com(n, b) << endl;
}

Measured memory_bytes: 3620
#pypyは内包表記使わない
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    A, B = map(int, input().split())
    res = 0
    for i in range(A, B+1):
        s = str(i)
        if s[0]==s[4] and s[1]==s[3]:
            res += 1
    print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
module module1
sub main()
    dim str as string
    str=console.readline()
    dim a as string()
    a = split(str)
    dim b as string
    if a(0) >= a(1) * 2 then
        b = a(0) - a(1) * 2
        console.writeline(b)
    else
        console.writeline(0)
    end if
End sub
end module

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


int main() {
  int a, b;
  cin >> a >> b;
  string ans = ":(";
  if(a < 9 && b < 9) ans = "Yay!";
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
  char str[255];
  scanf("%[^\n]", str);

  printf("%c", str[0] - 32);

  for(int i = 1; str[i] != '\0'; i++) {
    if(str[i] == ' ') {
      printf("%c", str[i+1] - 32);
    }
  }

  puts("");
  return 0;
}



Measured memory_bytes: 1592
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let x : Vec<i32> = get_vec();
    println!("{}", std::cmp::max(x[0] * x[1], x[2] * x[3]));
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	int N = S.size();
	int res = 0;
	int t = 0;
	int mn = 0;
	vector<int> X(N + 1, -100000);
	for (int i = 0; i < N - 1; i++) {
		if (S[i] == '>' && S[i + 1] == '<') {
			X[i + 1] = 0;
		}
	}
	if (S[0] == '<') {
		X[0] = 0;
	}
	if (S.back() == '>') {
		X.back() = 0;
	}
	for (int i = 1; i <= N; i++) {
		if (S[i - 1] == '<') {
			X[i] = max(X[i], X[i - 1] + 1);
		}
	}

	for (int i = N - 1; i >= 0; i--) {
		if (S[i] == '>') {
			X[i] = max(X[i], X[i + 1] + 1);
		}
	}

	for (int i = 1; i < N; i++) {
		if (S[i - 1] == '<' && S[i] == '>') {
			X[i] = max(X[i - 1], X[i + 1]) + 1;
		}
	}
	for (int i = 0; i <= N; i++) {
		res += X[i];
	}
	cout << res << endl;
}

Measured memory_bytes: 4892
#include <cstdio>
int b[23];
int a[23][23];
int main() {
    int n, m, c;
    scanf("%d %d %d",&n,&m,&c);
    for(int i = 0; i < m; i++) scanf("%d",&b[i]);
    for(int i = 0; i < n; i++) for(int j = 0; j < m; j++) scanf("%d",&a[i][j]);
    int ans = 0;
    for(int i = 0; i < n; i++) {
        int sum = c;
        for(int j = 0; j < m; j++) sum += a[i][j] * b[j];
        if(sum > 0) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    int N; cin >> N;
    vector<int>A(N);
    long long a = 1000;
    rep(i, N)cin >> A[i];
    int c = A[0];
    REP(j,N) {
        if (A[j] > c){
            a += (a / c) * (A[j] - c);
            c = A[j];
            j--;
        }
        else c = A[j];
    }
    cout << a << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;


class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        boolean[][] card = new boolean[4][13];
        int number = scan.nextInt();

        if (number == 52) {
            return;
        }
        while(number != 0) {
            char image = scan.next().charAt(0);
            int num = scan.nextInt() - 1;

            switch (image) {
                case 'S':
                    card[0][num] = true;
                    break;
                case 'H':
                    card[1][num] = true;
                    break;
                case 'C':
                    card[2][num] = true;
                    break;
                case 'D':
                    card[3][num] = true;
                    break;
            }
            number--;
        }
        for (int i = 0; i < 4; i++) {
            for(int j = 0; j < 13; j++) {
                if (card[i][j] == false) {
                    switch(i) {
                        case 0:
                            sb.append("S").append(" ").append(j + 1).append("\n");
                            break;
                        case 1:
                            sb.append("H").append(" ").append(j + 1).append("\n");
                            break;
                        case 2:
                            sb.append("C").append(" ").append(j + 1).append("\n");
                            break;
                        case 3:
                            sb.append("D").append(" ").append(j + 1).append("\n");
                            break;
                    }
                }
            }
        }
        sb.delete(sb.length() - 1, sb.length());
        System.out.println(sb);
    }
}

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

typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

ll sum(ll n,ll m){
  ll a = max(n,m);
  ll b = min(n,m);
  
  return (a * (a + 1) / 2 + b * (b - 1) / 2);
}

int main(){
  string s;
  cin >> s;
  
  ll n = s.size();
  
  vector<ll> a;
  
  ll count = 1;
  
  if(n == 1){
    cout << 1 << endl;
    return 0;
  }
  
  rep(i,n-1){
    if(s[i] == s[i+1]){
      count++;
    }else{
      a.PB(count);
      count = 1;
    }   
    if(i == n-2){
      a.PB(count);
    }
  }
  
  ll ans = 0;
  ll num = a.size();
  
  if(s[0] == '>'){
    ans += sum(0,a[0]);
    a.erase(a.begin());
    num--;
  }
  
  	rep(i,num/2) ans += sum(a[2 * i],a[2 * i + 1]);
  	if(num % 2 == 1){
    	ans += sum(a[num - 1],0);
 	}
  
  
  cout << ans << endl;
    
}

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

int a,b,newint,newintsq;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b;
	if(b < 10){
		newint = 10 * a + b;
		newintsq = sqrt(newint);
		if (newintsq * newintsq == newint) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}else if(b < 100){
		newint = 100 * a + b;
		newintsq = sqrt(newint);
		if (newintsq * newintsq == newint) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}else{
		newint = 1000 * a + b;
		newintsq = sqrt(newint);
		if (newintsq * newintsq == newint) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}


Measured memory_bytes: 256
n, c, k = map(int, input().split())
t = [int(input()) for i in range(n)]

t.sort()

diff = 0
cnt = 1
ans = 0
for i in range(n - 1):
    diff += abs(t[i + 1] - t[i])
    cnt += 1
    if diff > k or cnt > c:
        cnt = 1
        diff = 0
        ans += 1
print(ans + 1)


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int n;
double dp[301][301][301];

double solve(int a, int b, int c) {
  if (a==0 and b==0 and c==0) return 0;
  if (dp[a][b][c] >= 0) return dp[a][b][c];
  double ans = double(n) / double(a+b+c);
  if (a>0) ans += double(a) / (a+b+c) * solve(a-1, b, c);
  if (b>0) ans += double(b) / (a+b+c) * solve(a+1, b-1, c);
  if (c>0) ans += double(c) / (a+b+c) * solve(a, b+1, c-1);
  return dp[a][b][c] = ans;
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  memset(dp, -1, sizeof dp);
  cin >> n;

  vi f(4);
  rep(i,0,n) {
    int k;
    cin >> k;
    ++f[k];
  }

  cout << fixed << setprecision(20) << solve(f[1], f[2], f[3]) << '\n';
}

Measured memory_bytes: 213376
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

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; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve{
public:
    void input(){

    }
    void solve(){
        input();
        int a,b;
        cin >> a >> b;
        cout << a + b / 2 << endl;

    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int a[100000], b[100000];
int N, M;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> M;
    if(N%2 == 1){
        for(int i = 1; i <= M; i++){
            cout << i << ' ' << N-i+1 << endl;
        }
    }else{
        vector<int> e, o;
        for(int i = 1; i*2 < N; i++){
            if(i%2 == 1) o.push_back(i);
            else e.push_back(i);
        }
        int os = o.size();
        int es = e.size();
        int cnt = 0;
        for(int i = 0; i < os; i++){
            cout << i+1 << ' ' << 2*os-i << endl;
            cnt++;
            if(cnt >= M) return 0;
        }
        for(int i = 0; i < es; i++){
            cout << os*2+1+i << ' ' << os*2+(es+1)*2-(i+1) << endl;
            cnt++;
            if(cnt >= M) return 0;
        }
    }
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
#define k_p make_pair


int main()
{
    int n,k;
    while(cin>>n>>k)
    {
        vector<int> a(n+1);
        for(int i=1;i<=k;i++)
            cin>>a[i];
        int ans=0;
        for(int i=2;i<=k;i++)
            ans=max(ans,a[i]-a[i-1]);
        ans=max(a[1]+n-a[k],ans);
        cout<<n-ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int, int>;
static const int MAX = 100000;

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;

void dfs(int u) {
    V[u] = true;
    for (int i = 0; i < G[u].size(); i++) {
        int v = G[u][i];
        if (!V[v]) dfs(v);
    }
    out.push_front(u);
}

int main() {
    int s, t, M;

    cin >> N >> M;

    for (int i = 0; i < N; i++) V[i] = false;

    for (int i = 0; i < M; i++) {
        cin >> s >> t;
        G[s].push_back(t);
    }

    for (int i = 0; i < N; i++) {
        if ( !V[i]) dfs(i);
    }

    for (list<int>::iterator it = out.begin(); it != out.end(); it++)
        cout << *it << endl;

    return 0;
}


Measured memory_bytes: 6076
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll K; cin >> K;
    for(int t = 0; t < K;t++){
        ll a,b; cin >> a >> b;
        if(a*2 > N) a = N - a + 1;
        if(b*2 > N) b = N - b + 1;
        
        if(a < b) swap(a,b);
        if(b%3 == 1){
            cout << 1 << endl;
        }else if(b%3 == 2){
            cout << 2 << endl;
        }else{
            cout << 3 << endl;
        }
    }
    return 0;
}

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

int main() {
  int N, a, sum, output; 
  cin >> N; 

  vector<int>button(N); //ボタンの番号を代入する配列の初期化

  for (int i = 0; i < N; i++){
    cin >> button.at(i); //配列に代入
  }

  int next_button;
  next_button = button.at(0);
  if(next_button == 2){
    sum += 1;
    output = sum;
    cout << output << endl; //1回で2となる場合
  }
  else{ //2回以上で2となる場合
    for(sum = 2; sum < N + 1; sum++){ //2 <= sum <= N　でループ
      next_button = button.at(next_button - 1); //次のボタン番号
      if(next_button == 2){
        output = sum;
        break;
      }
      else{
          output = -1;
        }
      }
    cout << output << endl;
    }
  }

  

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L
#define PI 3.141592653589793238462643383279502884L

#define long long long int

using std::vector;
using std::map;
using std::set;
using std::string;
using std::pair;
using std::cin;
using std::cout;
using std::cerr;

// @author: pashka

vector<vector<int>> g;

long calc(int i, long s, int p) {
    long res = s;
    for (int x : g[i]) {
        if (x != p)
        res += calc(x, s + 1, i);
    }
    return res;
}

int main() {
    std::ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<pair<long, int>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }

    std::sort(a.rbegin(), a.rend());

    map<long, int> q;
    for (int i = 0; i < n; i++) {
        q[a[i].first] = i;
    }

    vector<int> s(n);

    g.resize(n);

    for (int i = 0; i < n - 1; i++) {
        s[i]++;
        long p = a[i].first - (n - 2 * s[i]);
        if (p >= a[i].first) {
            cout << -1;
            return 0;
        }
        if (q.find(p) == q.end()) {
            cout << -1;
            return 0;
        }
        int x = q[p];
        s[x] += s[i];
        g[x].push_back(i);
        g[i].push_back(x);
    }

    if (calc(n - 1, 0, -1) != a[n - 1].first) {
        cout << -1;
        return 0;
    }

//    for (int i = 0; i < n; i++) {
//        cerr << a[i] << " "<< calc(i, 0, -1) << "\n";
////        if (calc(i, 0, -1) != a[i]) cerr << "!!!";
//    }

    for (int i = 0; i < n; i++) {
        for (int j : g[i]) {
            if (j > i)
                cout << (a[i].second + 1) << " " << (a[j].second + 1) << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 20224
#include<bits/stdc++.h>
	#include <ext/pb_ds/assoc_container.hpp> 
	#include <ext/pb_ds/tree_policy.hpp> 
	using namespace __gnu_pbds;
	using namespace std;
	 
	#define ff                  first
	#define ss                  second
	#define endl                "\n"
	#define loop(i,s,e)         for(int i=s;i<e;i++)
	#define int                 long long
	#define vi                  vector<int> 
	#define S(v)                sort(v.begin(),v.end())
	#define RS(v)               sort(v.rbegin(),v.rend())
	#define R(v)                reverse(v.begin(),v.end())
	#define mxpq(T)             priority_queue <T>
	#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
	#define prv(v)              for(auto &x : v)cout << x << " ";
	#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
	#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
	#define mp                  make_pair
	#define pii                 pair<int,int>
	#define mset(a,f)           memset(a , f , sizeof(a))
	#define pb                  push_back
	#define inf                 INT_MAX
	#define INF                 LLONG_MAX
	typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
	 
	const int N = 2e6 + 6;
	const int M = 1e9+7;
	int A[N];
	int m;
	vector<int> vec;

	map<int,int> mmp;

	int id;

	void dfs(int x,int cnt)
	{
		if(mmp.count(x))
		{
			id = mmp[x]-1;
			return;
		}
		vec.pb(x);
		mmp[x] = cnt;
		int rt = (x*x)%m;
		dfs(rt,cnt+1);
	}

	void solve()
	{
		int n , x;
		cin >> n >> x >> m;
		x %= m;
		// cout << x;
		// return;
		dfs(x,1);

		int len = mmp.size();
		int len1 = len;
		// cout << len;return;

		// cout << vec[len-1] << " ";

		// if(x == 1)
		// {
		// 	cout << n;
		// 	return;
		// }

		if(n <= len)
		{
			int sum = 0;
			loop(i,0,n)sum += vec[i];
			cout << sum;
		}
		else 
		{
			int sum = 0;
			loop(i,0,len)sum += vec[i];
			n -= len;
			len -= id;
			if(len <= 1)
			{
				sum += (vec[vec.size()-1]*(n-vec.size()+1));
				cout << sum;
				return;
			}
			int rt = n/len;
			int sum1 = 0;
			loop(i,id,id+len)sum1 += vec[i];
			sum1 *= rt;
			int kt = n%len;
			int sum3= 0;
			loop(i,id,id+kt)sum3 += vec[i];
			cout << sum+sum1+sum3;
		}

	}			
	 
	int32_t main()
	{
	 
	cout<<fixed<<setprecision(16);
	 
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	 	
	 
	 	int t = 1;
	 	// cin >> t;
	 	while(t--)solve();
	  
	}

Measured memory_bytes: 10480
// ABC128-C https://atcoder.jp/contests/abc128/tasks/abc128_c
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define RFOR(i, a, b) for(int i = a; i >= b; --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const int INF = 1e9;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
int main() {
    int N, M;
    cin >> N >> M;
    vi a(N);
    int ans = 0;
    int p = 0;
    REP(i, M) {
        int k;
        cin >> k;
        REP(j, k) {
            int s;
            cin >> s;
            s--;
            // a[s]番目のビットを立てる
            a[s] |= 1 << i;
        }
    }
    REP(i, M){
        int x;
        cin >> x;
        // xが1のときi番目を立てる
        p |= x << i;
    }
    // Nに向かって全探索
    /*
        N = 8(1000)のとき
        iは000から111までループする
        bit全探索をしている
    */
    // このiは各スイッチのON/OFFを表現する
    // 001のときは1番目のスイッチを押したとき
    // これが全探索する部分
    FOR(i, 0, (1<<N)){
        int t = 0;
        REP(j, N) {
            // j番目のbitが立っていたら
            /*
                i = 100,j = 2のとき
                jによって2つシフトする
                iにおいてj番目のbitが立っているかどうかを判定することができる
            */
            if(i>>j & 1) {
                // 0と1を切り替えるときはXOR
                t ^= a[j];
            }
        }
        if(t == p) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
Al = [i for i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']
Num = [j for j in range(26)]
A = {key: value for key, value in zip(Al, Num)}
B = {key: value for key, value in zip(Num, Al)}
N = int(input())
S = [A[p] + N if A[p] + N < 26 else A[p] + N - 26 for p in input()]
ans = ''.join([B[q] for q in S])
print(ans)

Measured memory_bytes: 3188
# 降順にしたものを考え、最大のやつは1回、あとのやつは2回ずつ使える
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
ans = a[0]
count = n - 2
idx = 1
while count > 0:
    count_of_count = 2
    while count_of_count > 0 and count > 0:
        count -= 1
        count_of_count -= 1
        ans += a[idx]
    idx += 1
print(ans)

Measured memory_bytes: 31572
# 入力をプログラムで扱えるように受け取ること
a, b = map(int, input().split())
# print(a, b)
 
# 受け取った入力値を使い、適切に処理（計算）する
answer = a * b
 
# 計算した結果を出力する
print(answer)

Measured memory_bytes: 9140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	int r,d,n=10,i;
	ll x;
	cin >> r >> d >> x;
	for(i=0; i<n; ++i){
		x *= r;
		x -= d;
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{
  
  int p, l, r;

};

struct Node T[MAX];

int n;
int D[MAX], H[MAX];

int getDepth(int);
int getSibling(int);
void print(int);



int main(){
  
  int i;
  int v;
  int l, r;

  
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    
    T[i].p = NIL;
    
  }

  for ( i = 0; i < n; i++ ){
    
    scanf("%d %d %d", &v, &l, &r);

    T[v].l = l;
    T[v].r = r;

    if ( l != NIL ) {
      T[l].p = v;
    }
    
    if ( r != NIL ) {
      T[r].p = v;
    }
  }

  for ( i = 0; i < n; i++ ){
    
    D[i] = getDepth(i);
    H[i] = 0;

  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].l == NIL && T[i].r == NIL ) {
      
      H[i] = 0;

      
      int p = T[i].p;
      int c = 1;
      
      while(1){
	
	if ( p == NIL ) break;
	if ( H[p] < c ) {
	  H[p] = c;
	}
	
	c++;
	p = T[p].p;
	
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    print(i);
  }
  
  return 0;
}












int getDepth(int u){
  
  int d = 0;

  while(1){

    u = T[u].p;
    if ( u == NIL ) break;
    d++;

  }
  return d;
}


int getSibling(int u){
  
  if ( T[u].p == NIL ) return NIL;
  if ( T[T[u].p].l != u && T[T[u].p].l != NIL ) return T[T[u].p].l;
  if ( T[T[u].p].r != u && T[T[u].p].r != NIL ) return T[T[u].p].r;
  
  else  return NIL;
  
}

void print(int u){
  
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].p);
  printf("sibling = %d, ", getSibling(u));

  
  int deg = 0;
  
  if ( T[u].l != NIL ) deg++;
  if ( T[u].r != NIL ) deg++;

  
  printf("degree = %d, ", deg);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  
  if ( T[u].p == NIL ){
    
    printf("root\n");
    
  }
  else if ( T[u].l == NIL && T[u].r == NIL ){
    
    printf("leaf\n");
    
  }
  else {
    
    printf("internal node\n");
    
  }
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    string N;
    cin >> N;
    vector<vector<int>> dp(N.size() + 1, vector<int>(2, -1));
    dp[0][0] = 0;
    for(int i = 0; i < N.size(); i++) {
        if (dp[i][0] != -1) {
            // j = 0
            for(int k = 0; k <= N[i] - '0'; k++) {
                chmax(dp[i + 1][k != N[i] - '0'], dp[i][0] + k);
            }
        }
        if (dp[i][1] != -1) {
            // j = 1
            for(int k = 0; k <= 9; k++) {
                chmax(dp[i + 1][1], dp[i][1] + k);
            }
        }
    }

    cout << max(dp[N.size()][0], dp[N.size()][1]) << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
/*
Chase excellence, rating will come automatically.
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define inf 1e9
#define mod 1000000007
#define ff first
#define ss second

void solve()
{
    int x;
    cin >> x;
    cout << abs(1 - x) << "\n";
}

signed main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


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

typedef long long ll;
using namespace std;

const ll MOD = 1e9+7;
const ll INF = 1e18+7;

signed main(){

	int n;
	cin >> n;
	vector<int> a(n);
	for(auto& x : a)
		cin >> x;
	int t = a[0];
	for(int i = 1; i < n; ++i)
		t = __gcd(t, a[i]);
	cout << t << endl;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			// 整数の入力
			long n = sc.nextLong();
			// 文字列の入力
			String s = sc.next();

			int count = 0;

			for (int i = 0; i < n - 2; i++) {
				if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'B' && s.charAt(i + 2) == 'C') {
					count++;
				}
			}
			System.out.println(count);
		}
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  int dom = 0;
  int abr = 0;
  for (int i = 0; i < N; i++) {
    char s = S.at(i);
    if (s == 'c') {
      cout << "No" << '\n';
      continue;
    }
    if (s == 'a') {
      if (dom + abr < A + B) {
        cout << "Yes" << '\n';
        dom++;
      }
      else {
        cout << "No" << '\n';
        continue;
      }
    } else {
      if (dom + abr < A + B && abr < B) {
        cout << "Yes" << '\n';
        abr++;
      } else {
        cout << "No" << '\n';
      }
    }
  }
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define fil(x) memset(x, 0, sizeof(x))
#define fillb(x) memset(x,false,sizeof(x))
#define fillm(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define pll pair<int, int>
#define pf printf
#define sf scanf
#define all(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define fof(i,a,b) for(int i=a;i<=b;i++)
#define off(i,a,b) for(int i=a;i>=b;i--)
#define of(i,n) for(int i=n-1;i>=0;i--)
#define stl(i,x) for(auto i=x.begin(); i!=x.end();i++)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define nl endl

typedef unsigned long long lll;
typedef long long ll;
int knigtx8[] = {2, 2, -2, -2, 1, 1, -1, -1}; ///knight move in chess
int knigty8[] = {1, -1, 1, -1, 2, -2, 2, -2}; ///knight move in chess
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; ///for 8 directions
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1}; ///for 8 directions
int dx4[] = {0, 0, 1, -1}; ///for 4 directions
int dy4[] = {1, -1, 0, 0}; ///for 4 directions
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}
ll pw(ll a, ll b)
{
    ll ans = 1;
    for(ll i = 1; i <= b; ++i)
        ans = (ans * a);
    return ans;
}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

int main()
{
    IOS;
    int n;
    cin>>n;
    //int k = n/1000;
    if(n<1000){
        cout<<1000-n<<endl;
        return 0;
    }
    int r = n%1000;
  	//if(r>500)r=1000-r;
    if(r==0)cout<<0<<endl;
    else cout<<1000-r<<endl;
    return 0;
}

///Alhamdulillah


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

int main(){
  string str;
  cin >> str;

  int ans = 0;

  rep(i, 4){
    if(str.at(i) == '+'){
      ans++;
    }
    else{
      ans--;
    }
  }

  cout << ans << endl;
}

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


int main()
{
	int n,r=0;
	cin >> n;
	string s[n];
	for(int i=0;i<n;i++)
		cin >> s[i];
	sort(s,s+n);
	for(int i=0;i<n-1;i++)
	{
		if(s[i]==s[i+1])
			r++;
	}
	/*for(int i=0;i<n;i++)
	{
		cout << s[i] << endl;

	}*/
	cout << n-r ;

}


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

int main() {
  int N,L;cin>>N>>L;
  vector<string> S(N);
  for(int i=0; i<N; i++)cin>>S[i];
  sort(S.begin(),S.end());
  string ans="";
  for(int i=0; i<N; i++){
    ans+=S[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

list = [1]*1000000
list[0] = 0
list[1] = 0
for i in range(1, 1000000):
    if list[i] == 1:
        for j in range(i**2, 1000000, i):
            list[j] = 0

for i in range(2, 1000000):
    list[i] += list[i -1]
while True:
    try:
        n = int(raw_input())
        print(list[n])
    except EOFError:
        break

Measured memory_bytes: 67708
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
//const long mod=(long)1e9+7;
const long INF=1L<<60;
long dp[1<<17];
inline void solve(void){
  long H,N;in(H,N);
  vector<pair<int,int>>C;
  rep(i,N){
    int A,B;in(A,B);
    C.pb(mp(A,B));
  }
  sort(all(C));
  rep(i,1L<<17)dp[i]=INF;
  dp[0]=0;
  up(h,1,H){
    rep(i,N){
      chmin(dp[h],dp[max(h-C[i].ft,0)]+C[i].sd);
    }
  }
  out(dp[H]);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int A, P;
    cin >> A >> P;

    cout << (3 *A + P) / 2 << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
int lcm(int a, int b) {
	return a / gcd(a, b)*b;
}
int modpow(int a,int b){
    if(!b)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int fac(int a){
    int Ans=1;
    for(int i=1;i<=a;i++){
        Ans*=i;
        Ans%=MOD;
    }
    return Ans;
}//kaijo
int comb(int a,int b){
    return fac(a)*modpow(fac(a-b),MOD-2)%MOD*modpow(fac(b),MOD-2)%MOD;
}

int main(){
	string s;
	cin>>s;
	int ans=0;
	if(s[0]=='2')ans++;
	if(s[1]=='2')ans++;
	if(s[2]=='2')ans++;
	if(s[3]=='2')ans++;
	cout<<ans<<endl;
	return 0;
}



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

const int inf = 1e9;
const ll linf = 1e18;

int rec(int v, const vector<vector<int>> &g, vector<int> &dp, vector<bool> &visited)
{
    if (visited[v]) return dp[v];
    visited[v] = true;
    int res = 0;
    for (auto nv: g[v]) {
        res = max(res, rec(nv, g, dp, visited) + 1);
    }
    return dp[v] = res;
}

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

    int n, m; cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        int x, y; 
        cin >> x >> y;
        x--, y--;
        g[x].push_back(y);
    }
    
    vector<int> dp(n, 0);
    vector<bool> visited(n, false);
    for (int i = 0; i < n; i++) rec(i, g, dp, visited);

    int ans = *max_element(dp.begin(), dp.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int H[]=new int[N];
		int z=1,max=0,cou=1;
		H[0]=stdIn.nextInt();
		max=H[0];
		while(z<N){
			H[z]=stdIn.nextInt();
			if(max<=H[z]){
				max=H[z];
				cou++;
			}
			z++;
		}
		System.out.println(cou);
	}
}

Measured memory_bytes: 21844
import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created 2017/06/01.
 */
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    ArrayList<Integer> ary = new ArrayList<>();

    for (int i = 0; i < 3; i++) {
      int input = sc.nextInt();
      ary.add(input);
    }

    int a = ary.get(0);
    int b = ary.get(1);
    int c = ary.get(2);

    if (a < b && b < c) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 26276
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
const int N = 5;

int main(){
    vector<int> v(N);
    REP(i, N) cin >>v[i];
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    cout <<v[0];
    FOR(i, 1, N) cout <<" " <<v[i];
    cout <<endl;
    return 0;
}

Measured memory_bytes: 1208