akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/range/numeric.hpp>

#ifdef _MSC_FULL_VER
#include"randomizer.hpp"
#include"debug_print.hpp"
#endif

#include<cstdlib>
#include<ctime>

namespace lib
{
	template<class T>using pair = std::pair<T, T>;
	template<class T>constexpr T pow(T base, std::uint64_t p)
	{
		T ret = T(1);
		for (std::uint64_t i = 0; i <= 63; ++i)
		{
			if (((1ull << i) & p) != 0)
			{
				ret *= base;
			}
			base *= base;
		}
		return ret;
	}
	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;

	struct union_find
	{
		std::vector<int> upper;
		union_find(std::size_t size):upper(size, -1) {}

		int group(int index)
		{
			if (upper[index] == -1)
			{
				return index;
			}
			else
			{
				return upper[index] = group(upper[index]);
			}
		}

		bool merge(int x, int y)
		{
			auto gx = group(x);
			auto gy = group(y);
			if (gx != gy)
			{
				upper[gx] = gy;
				return true;
			}
			return false;
		}

		auto get()
		{
			std::map<int, std::set<int>> ret;
			for (int i = 0; i < upper.size(); ++i)
			{
				ret[group(i)].emplace(i);
			}
			return ret;
		}

		auto tops()
		{
			std::set<int> ret;
			for (int i = 0; i < upper.size(); ++i)
			{
				ret.emplace(group(i));
			}
			return ret;
		}

		bool is_same_group(int x, int y)
		{
			return group(x) == group(y);
		}
	};
}

namespace out
{
	namespace detail
	{
		template<class>struct void_out
		{
			typedef void type;
		};
		template<class T>auto write(std::ostream& ost, T const& val)
			->typename void_out<decltype(ost << val)>::type
		{
			ost << val;
		}
		template<class T, class... Ts>void write(std::ostream& ost, T const& val, Ts const&... nexts)
		{
			write(ost, val);
			ost << " ";
			write(ost, nexts...);
		}
	}
	void write_line()
	{
		std::cout << std::endl;
	}
	template<class...Ts>void write_line(Ts const&... args)
	{
		detail::write(std::cout, args...);
		write_line();
	}
	template<class Range>void write_range(Range const& rng)
	{
		for (auto const& v : rng)
		{
			write_line(v);
		}
	}
}
namespace adaptor = boost::adaptors;

void Main()
{
	int N;
	std::cin >> N;
	std::vector<int> target(N);
	for (auto& v : target)
	{
		std::cin >> v;
	}
	std::set<int> set;
	std::vector<int> result(N);
	for (auto i : boost::irange(0, N))
	{
		set.emplace(i);
	}
	for (auto v : target | adaptor::reversed)
	{
		if (set.size() < v)
		{
			out::write_line(-1);
			return;
		}
		auto t = *std::next(set.begin(), v - 1);
		result[t] = v;
		set.erase(t);
	}
	for (auto v : result)
	{
		out::write_line(v);
	}
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define si short int
using namespace std;
#define MOD 1000000007

int main(){
	int N;
	cin >> N;
	int arr[N+1][3];

	for(int i=1;i<=N;i++){
		cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
	}

	ll dp[N+5][3];
	memset(dp, 0, sizeof(dp));

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

	for(int i=2;i<=N;i++){
		dp[i][0] += arr[i][0] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] += arr[i][1] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] += arr[i][2] + max(dp[i-1][0], dp[i-1][1]);
	}

	cout << max({dp[N][0], dp[N][1], dp[N][2]});
}

Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<vector>
int func(std::vector<int>&num)
{
	const size_t size = num.size();
	if (size == 1)
	{
		return num[0];
	}
	std::vector<int>result(size - 1);
	for (int i = 0; i < size - 1; i++)
	{
		result[i] = (num[i] + num[i + 1]) % 10;
	}
	return func(result);
}
int main()
{
	std::vector<int>num(10);
	while (true)
	{
		std::string num_str;
		std::cin >> num_str;
		if (std::cin.eof())
		{
			break;
		}
		for (int i = 0; i < 10; i++)
		{
			num[i] = static_cast<int>(num_str[i] - '0');
		}
		std::cout << func(num) << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100],m[100],v[100];
long long sum;
bool cmp(int x,int y){
	return x>y;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>m[i];
		v[i]=a[i]-m[i];
	}
	sort(v,v+n,cmp);
	for(int i=0;i<n;i++){
		if(v[i]>0){
			sum+=v[i];
		}
	}
	cout<<sum;
 }

Measured memory_bytes: 256
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String retu = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
		String[] s = retu.split(", ");
		System.out.println(s[sc.nextInt() - 1]);
	}
}


Measured memory_bytes: 35668
#include <stdio.h>

int main(void) {
  double a, s, t;
  int i;
  
  while(scanf("%lf", &a) != EOF) {
    s = a;
    t = a;
    for (i = 2; i <= 10; i++) {
      if (i % 2)
	t /= 3.0;
      else
	t *= 2.0;
      s += t;
    }
    printf("%.7lf\n", s);
  }
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  int st, e;

    for (int i=0; i<s.size(); i++){
      if (s[i]=='A'){
        st = i;
          break;
      }
    }
   for (int i=0; i<s.size(); i++){
      if (s[s.size()-i-1]=='Z'){
        e = s.size()-i-1;
          break;
      }
    }
  cout << e-st+1 << endl;
        
  
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
using namespace std;

int n,lr[100005],put[100005];
char c[100005];
//0-->S 1-->W
void print(){
	for(int i=1;i<=n;i++)
	if(put[i]==0)printf("S");
	else printf("W");
}

void work(int num1,int num2){
	memset(put,0,sizeof(put));
	put[1]=num1;
	put[2]=num2;
	for(int i=2;i<=n;i++){
		if((c[i]=='x'&&put[i]==1)||(c[i]=='o'&&put[i]==0))
		put[i+1]=put[i-1];
		if((c[i]=='o'&&put[i]==1)||(c[i]=='x'&&put[i]==0))
		put[i+1]=1-put[i-1];
	}
	if(((c[1]=='x'&&put[1]==1)||(c[1]=='o'&&put[1]==0))&&put[2]==put[n]&&put[n+1]==put[1]){
		print();
		exit(0);
	}
	if(((c[1]=='o'&&put[1]==1)||(c[1]=='x'&&put[1]==0))&&put[2]+put[n]==1&&put[n+1]==put[1]){
		print();
		exit(0);
	}
}

int main(void){
	scanf("%d",&n);
	scanf("%s",c+1);
	for(int i=0;i<=1;i++){
		for(int j=0;j<=1;j++){
			work(i,j);
		}
	} 
	printf("-1");
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,k,r,s,p;ll ans;
int dp[100005][3],a[3];
char t[100005];
map<char,int>mp;
int main()
{
    n=read(),k=read();
    r=read(),s=read(),p=read();
    a[0]=r,a[1]=s,a[2]=p;
    mp['r']=0,mp['s']=1,mp['p']=2;
    cin>>(t+1);reg int i,j,tmp,h,g;
    for(i=1;i<=k;++i)
    {
        if(mp[t[i]]==0)dp[i][2]=a[2];
        if(mp[t[i]]==1)dp[i][0]=a[0];
        if(mp[t[i]]==2)dp[i][1]=a[1];
        for(j=i+k;j<=n;j+=k)
        {
            if(mp[t[j]]==0)tmp=2;
            if(mp[t[j]]==1)tmp=0;
            if(mp[t[j]]==2)tmp=1;
            for(h=0;h<=2;++h)
            {
                for(g=0;g<=2;++g)
                {
                    if(g==h)continue;
                    dp[j][h]=max(dp[j][h],dp[j-k][g]+(tmp==h)*a[h]);
                }
            }
        }
    }
    for(i=n-k+1;i<=n;++i)
    {
        tmp=max(dp[i][0],max(dp[i][1],dp[i][2]));
        ans+=tmp;
    }
    cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 1536
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>
 
using namespace std;
 
using ll = long long int; 
 
void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;
 
    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}
 
 
ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}
 
ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}
 
const int MAX = 50;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

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

  vector<vector<pair<int, int>>> v(n);

  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    for(int j=0;j<a;j++){
      int x, y;
      cin>>x>>y;
      pair<int, int> p = make_pair(x, y);
      v[i].push_back(p);
    }
  }

  int flag;
  int ans = 0;

  //正直者の集合
  for(int bit=0;bit<(1<<n);++bit){
    flag = 0;
    for(int i=0;i<n;i++){
      if(bit & (1<<i)){//iが正直の時
        for(int j=0;j<v[i].size();j++){
          if(bit & (1<<v[i][j].first -1)){
            if(v[i][j].second !=1) flag = 1;
          }else{
            if(v[i][j].second ==1) flag = 1;
          }
        }
      }
      //if(flag==1) break;
    }
   // cout<<flag<<endl;
    if(flag==0) ans = max(ans, counter(bit));
  }
  cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

int main () {
    int k, s ;
    int ans = 0 ;
    cin >> k >> s ;
    rep(i, k + 1){
        rep(j, k + 1){
            int t = s - (i + j) ;
            if(t > k || t < 0) continue ;
            ans++ ;
        }
    }
    cout << ans << endl ;
}



Measured memory_bytes: 3624
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N, C;
	int D[30][30];
	int c[500][500];
	int sum[3][30];
	cin >> N >> C;

	REP(i, C) {
		REP(j, C){
			cin >> D[i][j];
		}
	}

	REP(i, N) {
		REP(j, N) {
			cin >> c[i][j];
		}
	}

	REP(k, N) {
		REP(i, 3) {
			int a;
			if (k % 3 == 0)
				a = i;
			else if (k % 3 == 1)
				a = i-1;
			else
				a = i-2;
			while (a < N) {
				
				REP(j, C) {
					if(a>=0)
						sum[i][j] += D[c[k][a]-1][j];
				}

				a += 3;
			}
		}
	}

	int ans = LLINF;
	REP(i, C) {
		REP(j, C) {
			REP(k, C) {
				if (i != j && j != k && i != k) {
					int cnt = sum[0][i] + sum[1][j] + sum[2][k];
					ans = min(ans, cnt);
				}
			}
		}
	}

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



Measured memory_bytes: 2176
n, m = [int(x) for x in input().split(' ')]
s = [[int(x) for x in input().split(' ')[1:]] for _ in range(m)]
p = input().split(' ')

cnt = 0
for i in range(0, 2**n):
    ptn = '0'+format(i, '010b')[::-1]
    light = []
    for j, sw in enumerate(s):
        on_sws = [ptn[sw_i] for sw_i in sw if ptn[sw_i] == '1']
        light.append(len(on_sws) % 2 == int(p[j]))
    if all(light):
        cnt += 1

print(cnt)


Measured memory_bytes: 3188
#include "iostream"
using namespace std;
 
int main(){
  int X;
  int hund, nh, usehund;
  
  cin >> X;
  
  hund = (int)(X/100);
  
  nh = X - hund*100;
  
  usehund = (int)((nh + 4)/5) ;
  
  
  if(hund >= usehund) cout << 1;
  else cout << 0;
  
 return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;
int main(){
	int n; cin >>n;
	vector<int> a(n);
	cinf(n,a);
	int res=0; int ans=1;
	for(int i=1;i<n;i++){
		int s=a[i]-a[i-1];
		if(res<0&&s>0 || res>0 && s<0){
			ans++;
			res=0;
		}
		else if(s)res=s;
	}
	cout << ans << endl;
}


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

using namespace std;
int main() {
    string S;
    cin >> S;
    if(S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}

use std::cmp::{max, min};

fn main() {
    let n: String = read();
    let n_char: Vec<char> = n.chars().collect();

    let n_len = n_char.len();
    let mut cnt: i64 = 0;

    if n_len == 1 {
      println!("{}", 0);
      return 
    }

    if n_len % 2 == 1 {
      // 奇数の場合
      let front = &n_char[0..n_len / 2 + 1];
      let back = &n_char[n_len / 2..];
    
      for (i, v) in front.iter().enumerate() {
        if *v != back[back.len() - i - 1] {
          cnt +=1;
        }
      }
    } else {
      // 偶数の場合
      let front = &n_char[0..n_len / 2];
      let back = &n_char[n_len / 2..];
    
      for (i, v) in front.iter().enumerate() {
        if *v != back[back.len() - i - 1] {
          cnt +=1;
        }
      }
    }

    println!("{}", cnt)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define MN 100005
int n,m;
LL sum;
char ch[5];
int vis[MN],WA[MN],cnt1,cnt2;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;++i){
		char ch[5];
		int a;
		scanf("%d%s",&a,ch);
		if(ch[0]=='A'&&!vis[a])cnt1++,cnt2+=WA[a],vis[a]=1;
		else if(ch[0]=='W')WA[a]++;
	}
	printf("%d %d\n",cnt1,cnt2);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	while(getline(cin,s)){
		for(int i=0;i<26;++i){
			for(int j=0;j<s.size();++j) if('a'<=s[j]&&s[j]<='z') s[j]=((s[j]-'a'+1)%26+'a');
			if(s.find("the")!=-1||s.find("this")!=-1||s.find("that")!=-1)break;
		}
		cout<<s<<endl;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h.at(i);
    
    int count = 0, sum = 0;
    do {
        sum = 0;
        int prev = 0;
        rep(i,n) {
            if (0 < h.at(i)) {
                if (prev == 0) count++;
                prev = h.at(i);
                h.at(i)--;
                sum += h.at(i);
            }
            else prev = 0;
        }
    } while (sum != 0);
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3632
import sys

# import re
# import math
# import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
# import copy
# import heapq
# import decimal
# import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 10
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    h, w = ns()
    mat = [list(sys.stdin.readline()) for _ in range(h)]

    def bfs(x, y):
        arrived_mat = [[False for i in range(w)] for j in range(h)]

        que = queue.Queue()
        que.put((x, y, 1))
        arrived_mat[y][x] = True
        res = 0

        direc = [(0, 1), (0, -1), (1, 0), (-1, 0)]

        while que.qsize() > 0:
            xi, yi, cnt = que.get()

            for dx, dy in direc:
                next_x = xi + dx
                next_y = yi + dy
                if -1 < next_x < w and -1 < next_y < h:
                    if mat[next_y][next_x] == "." and arrived_mat[next_y][next_x] != True:
                        que.put((next_x, next_y, cnt + 1))
                        arrived_mat[next_y][next_x] = True                        
                        res = max(res, cnt + 1)

        return res

    ans = 0
    for y in range(h):
        for x in range(w):
            if mat[y][x] == ".":
                ans = max(ans, bfs(x, y) - 1)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4080
/*
	AOJ_0551: Icicle
*/

#include	<iostream>
#include	<queue>
#include	<vector>
#include	<utility>

using namespace std;

typedef pair<int, int> PAIR;

class Icicles {
private:
	int datas[100002];
	int num;
	int limit;
	bool checkGrowth(int index) {
		if (datas[index] > datas[index + 1] && datas[index] > datas[index - 1]) { return true; }
		return false;
	}
public:
	void data_inserting(int n, int l, vector<int> &order) {
		num = n;
		limit = l;
		datas[0] = 0;
		for (int i = 0; i < order.size(); i++) {
			datas[1 + i] = order[i];
		}
		datas[num + 1] = 0;
	}
	int calc(void) {
		int result = 0, buff;
		PAIR _p, _lf, _ri;

		priority_queue<PAIR> PQ;
		for (int i = 0; i < num; i++) {
			if (checkGrowth(i+1)) { PQ.push(PAIR(datas[i+1], i+1)); }
		}
		while (!PQ.empty()) {
			_p = PQ.top();
			PQ.pop();
			buff = limit - (_p.first + result);
			result += buff > 0 ? buff : 0;
			datas[_p.second] = 0;
			if (checkGrowth(_p.second - 1)) {
				PQ.push(PAIR(datas[_p.second - 1] - result, _p.second - 1));
			}
			if (checkGrowth(_p.second + 1)) {
				PQ.push(PAIR(datas[_p.second + 1] - result, _p.second + 1));
			}
		}
		return result;
	}
};

int main(void) {
	int N, L, buff;
	while (1) {
		vector<int> order;
		Icicles I;

		cin >> N >> L;
		if (cin.eof()) { break; }

		for (int i = 0; i < N; i++) {
			cin >> buff;
			order.push_back(buff);
		}
		I.data_inserting(N, L, order);
		cout << I.calc() << endl;
	}
	return 0;
}

Measured memory_bytes: 2608
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <type_traits>
#include <limits>
#include <tuple>

template <class Tp>
class lines {
  // based on Li Chao tree
  std::map<Tp, size_t> enc;
  std::vector<Tp> dec;
  std::vector<std::pair<Tp, Tp>> c;
  size_t m = 1;
  Tp inf = std::numeric_limits<Tp>::max() / 8;

private:
  void init_resize(size_t n) {
    while (m < n+n) m <<= 1;
    c.assign(m, {0, inf});
  }

  void inspect() const {
    for (size_t i = 1; i < m; ++i) {
      std::string s = (c[i].first < inf? std::to_string(c[i].first) : "inf");
      std::string t = (c[i].second < inf? std::to_string(c[i].second) : "inf");
      fprintf(stderr, "(%s, %s)%c", s.c_str(), t.c_str(), (i&(i+1))? ' ':'\n');
    }
  }

public:
  template <class ForwardIt>
  lines(ForwardIt first, ForwardIt last): dec(first, last) {
    static_assert(std::is_same<typename ForwardIt::value_type, Tp>::value, "Type mismatch");
    std::sort(dec.begin(), dec.end());
    size_t n = dec.size();
    init_resize(n);
    // while (dec.size() < m/2) dec.push_back(dec.back()+1);
    dec.resize(m/2, dec.back());
    for (size_t i = 0; i < m/2; ++i) enc.emplace(dec[i], i);
  }

  void append(Tp a, Tp b) {
    size_t l = 0;
    size_t j = 1;
    size_t h = 1;
    size_t w = m/2;
    while (w > 1 && l+w-1 < dec.size()) {
      Tp xl = dec.at(l);
      Tp xm = dec.at(l+w/2);
      Tp xr = dec.at(l+w-1);

      Tp a0, b0;
      std::tie(a0, b0) = c[j];

      Tp yl0 = a0*xl + b0;
      Tp ym0 = a0*xm + b0;
      Tp yr0 = a0*xr + b0;

      Tp yl = a*xl + b;
      Tp ym = a*xm + b;
      Tp yr = a*xr + b;

      if (yl0 <= yl && yr0 <= yr) break;
      if (yl0 >= yl && yr0 >= yr) {
        c[j] = {a, b};
        break;
      }

      h <<= 1;
      w >>= 1;

      if (ym0 >= ym) {
        c[j] = {a, b};
        a = a0;
        b = b0;
        j <<= 1;
        if (yr0 < yr) {
          j |= 1;
          l += w;
        }
      } else {
        j <<= 1;
        if (yr0 >= yr) {
          j |= 1;
          l += w;
        }
      }
    }
  }

  Tp min_at(Tp x) const {
    size_t i = enc.at(x) + m/2;
    Tp y = inf;
    while (i > 0) {
      Tp a, b;
      std::tie(a, b) = c[i];
      y = std::min(y, a*x+b);
      i >>= 1;
    }
    return y;
  }
};

int main() {
  size_t N;
  intmax_t C;
  scanf("%zu %jd", &N, &C);

  std::vector<intmax_t> h(N);
  for (auto& hi: h) scanf("%jd", &hi);

  lines<intmax_t> cht(h.begin(), h.end());

  std::vector<intmax_t> dp(N);
  for (size_t i = 0; i+1 < N; ++i) {
    cht.append(-2*h[i], h[i]*h[i]+dp[i]);
    dp[i+1] = cht.min_at(h[i+1]) + h[i+1]*h[i+1] + C;
  }

  printf("%jd\n", dp[N-1]);
}


Measured memory_bytes: 27112
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    static int[] w = new int[100010];
    static int[] v = new int[100010];
    static int[][] dp = new int[110][100010];
    static int k;

    static int chmin(int a, int b) {
        if (a > b) {
            a = b;
            return a;
        }
        return a;
    }

    static int chmax(int a, int b) {
        if (a < b) {
            a = b;
            return a;
        }
        return a;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = sc.nextInt();
        System.out.println(24 + 24 - m);
    }
}


Measured memory_bytes: 82132
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
bool isprime(int n){
    for(int i=2;i<n;i++){
        if(n%i==0) return false;
    }
    return true;
}
int div(int n){
    int c=1,temp=7;
    while(temp%n!=0){
        temp=(temp%n)*10+7;
        c++;
    }
    return c;
}
int main()
{
    int n;
    cin>>n;
    if(n%2==0 || n%5==0){
        cout<<-1;
        return 0;
    }
    cout<<div(n);
    return 0;
}


Measured memory_bytes: 3604
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void Solve()
{
    int64_t N, K;
	std::cin >> N;
	std::cin >> K;

	// a + b = K * s
	// b + c = K * t
	// b + c = K * u
	// a + b + c = K * 1/2 * (s + t + u)
	// K = K' * 2とすると
	// a + b + c = K' * (s + t + u)
	// 両辺のmod K'をとると、a, b, cのmod K'は0になるので
	// a, b, cのmod Kは 0 or K/2
	// Kが奇数のときはa, b, cのmod Kは0

	int64_t zero = 0;
	int64_t half = 0;
	for (int64_t i = 1; i <= N; i++) {
		if(i % K == 0) zero++;
		if(i % K == K / 2) half++;
	}
	
	int64_t ans = 0;
	if (K % 2 == 0) {
		int64_t ans1 = zero * zero * zero;
		int64_t ans2 = half * half * half;
		ans = ans1 + ans2;
	} else {
		ans = zero * zero * zero;
	}

	std::cout << ans << std::endl;

}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Solve();
}


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

typedef long long ll;
typedef pair<int,int> P;
const ll INF = 1LL<<60;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,w;
    cin >> n >> w;
    vector<vector<ll>> dp(n+1,vector<ll>(100010,INF));
    dp[0][0] = 0;
    for (int i = 0;i < n;++i) {
        int u,v;
        cin >> u >> v;
        dp[i+1] = dp[i];
        for (int j = 0;j < 100010-v;++j) {
            dp[i+1][j+v] = min(dp[i+1][j+v],dp[i][j]+u);
        }
    }
    int ans = 0;
    for (int i = 0;i < 100010;++i) if (dp[n][i] <= w) ans = i;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80256
fun main(args: Array<String>) = println(run {
    val n = readLine()!!.toInt()
    val h = readLine()!!.split(" ").map { it.toInt() }.toIntArray()

    h[0]--
    for (i in 1..h.lastIndex) {
        when {
            h[i] > h[i-1] -> h[i]--
            h[i] < h[i-1] -> return@run "No"
        }
    }
    "Yes"

})

Measured memory_bytes: 57860
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>
#include <bitset>

#include <stack>

using namespace std;

typedef pair<long long int, long long int> P;
typedef pair<long long int, P> P2;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
// long long int MOD = 1e9 + 7;
long long int MOD = 998244353;

vector<int> E[210000];

long long int func(int pos){
	long long int ret = 1;
	for(int to : E[pos]){
		ret *= func(to);
		ret %= MOD;
	}
	return ret + 1;
}

int main(){
	int N;
	cin >> N;
	vector<P> v;
	for(int i = 0; i < N; i++){
		long long int X, D;
		cin >> X >> D;
		v.push_back(P(X, D));
	}
	sort(v.begin(), v.end());
	stack<int> st;
	for(int i = 0; i < N; i++){
		int id;
		while(!st.empty()){
			id = st.top();
			if(v[id].first + v[id].second > v[i].first){
				break;
			}
			st.pop();
		}
		if(st.empty()){
			E[200200].push_back(i);
		}else{
			E[id].push_back(i);
		}
		st.push(i);
	}
	cout << (func(200200) + MOD - 1) % MOD << endl;
	return 0;
}


Measured memory_bytes: 24812
import operator
S = input()
nums = []
for s in S:
    nums.append(int(s))

ope = {'+': operator.add, '-': operator.sub}
idx = {0:'+', 1:'-'}
for i in range(2):
    ans1 = ope[idx[i]](nums[0], nums[1])
    for j in range(2):
        ans2 = ope[idx[j]](ans1, nums[2])
        for k in range(2):
            if ope[idx[k]](ans2, nums[3]) == 7:
                print(str(nums[0])+idx[i]+str(nums[1])+idx[j]+str(nums[2])+idx[k]+str(nums[3])+'=7')
                quit()

Measured memory_bytes: 3064
n = int(input())
line = input()
L = [int(x) for x in line.split()]

flags = [False] * n
loops = []

S = sorted(L)
I = [S.index(x) for x in L]
for idx, x in enumerate(I):
    if flags[x]:
        continue
    if x == idx:
        flags[idx] = True
        continue

    ws = []
    while S[x] not in ws:
        flags[x] = True
        ws.append(S[x])
        x = I[x]
    loops.append(ws)

cost = 0
for loop in loops:
    a = sum(loop) + (len(loop) - 2) * min(loop)
    b = sum(loop) + min(loop) + (len(loop) + 1) * min(L)
    cost += min(a, b)

print(cost)

Measured memory_bytes: 5716
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<set>
#define N 2005
using namespace std;
int i,j,k,l,s,n,m,a[N][N],b[N][N],ans;
set<int>GT;
set<int>::iterator GTW;
struct node {
	int x,v;
}q[N];
char c;
inline bool cmp(node x,node y) {
	return x.v<y.v;
}
int main() {
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++) for (j=1;j<=m;j++) {
		c=getchar();
		while (c!='#'&&c!='.') c=getchar();
		if (c=='#') a[i][j]=1;
		else a[i][j]=0;
	}
	for (i=1;i<=m;i++) b[1][i]=m;
	for (i=2;i<=n;i++) {
		int j=1;
		while (j<=m) {
			int bb;
			if (a[i][j]==a[i-1][j]) bb=0;
			else bb=1;
			k=j+1;
			while (k<=m) {
				if (abs(a[i][k]-a[i-1][k])!=bb) break;
				k++;
			}
			for (;j<k;j++) b[i][j]=k-1;
		}
	}
	ans=m;
/*	for (i=2;i<=n;i++)
	for (j=1;j<=m;j++) {
		int L=i;
		for (k=i-1;k>1;k--) {
			if (b[k][j]<b[i][j]) break;
			L=k;
		}
		int R=i;
		for (k=i+1;k<=n;k++) {
			if (b[k][j]<b[i][j]) break;
			R=k;
		}
		ans=max(ans,(R-L+2)*(b[i][j]-j+1));
	}
	printf("%d\n",ans);*/
	for (i=1;i<=m;i++) {
		for (j=2;j<=n;j++) q[j-1].v=b[j][i],q[j-1].x=j;
		sort(q+1,q+n,cmp);
		for (j=1;j<n;) {
			int k=j+1;
			int L,R;
			while (k<n&&q[k].v==q[j].v) k++;
			int ii=j;
			for (;j<k;j++) {
				GTW=GT.lower_bound(q[j].x);
				if (GTW==GT.end()) R=n;
				else R=(*GTW)-1;
				if (GTW==GT.begin()) L=2;
				else GTW--,L=(*GTW)+1;
				ans=max(ans,(R-L+2)*(q[j].v-i+1));
			}
			j=ii;
			for (;j<k;j++) GT.insert(q[j].x);
		}
		GT.clear();
	}
	printf("%d\n",ans);
}


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

int main() {
  long n;
  long sum = 0;
  cin >> n;
  for (long i = 1; i * i < n; i++) {
    if (n % i == 0 && n / i > 2 && n / i - 1 != i)
      sum += n / i - 1;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
lm=[]
m1=m
if m!=0:
  while m1!=0:
    lm.append(m1%2)
    m1=m1//2
else:
  lm=[0]
ln=[]
n1=n-1
if n!=0:
  while n1!=0:
    ln.append(n1%2)
    n1=n1//2
while len(ln)!=len(lm):
  ln.append(0)
if n!=0:
  lm1=[0 for i in range(len(lm))]
  ln1=[0 for i in range(len(ln))]
  if lm[0]!=lm[1]:
    lm1[0]=1
  if ln[0]!=ln[1]:
    ln1[0]=1
  for i in range(1,len(lm)):
    if lm[i]==1 and lm[0]==0:
      lm1[i]=1
  for i in range(1,len(ln)):
    if ln[i]==1 and ln[0]==0:
      ln1[i]=1
  lmn=[0 for i in range(len(lm))]
  for i in range(len(lm)):
    if lm1[i]==ln1[i]:
      pass
    else:
      lmn[i]=1
  s=1
  ss=0
  for i in lmn:
    ss+=s*i
    s*=2
  print(ss)
else:
  print(m)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;



int main(){
    int n;
    cin>>n;
    ll dp[110][4][4][4]={};
    rep(i,4){
        rep(j,4){
            rep(k,4){
                dp[3][i][j][k]=1;
            }
        }
    }
    dp[3][0][1][2]=0,dp[3][0][2][1]=0,dp[3][1][0][2]=0;
    for(int i=3;i<n;i++){
        rep(j,4){
            rep(k,4){
                rep(l,4){
                    if(dp[i][j][k][l]==0) continue;
                    rep(m,4){
                        if((k==0&&l==1&&m==2)||(k==0&&l==2&&m==1)||(k==1&&l==0&&m==2)||(j==0&&l==1&&m==2)||(j==0&&k==1&&m==2)) continue;
                        dp[i+1][k][l][m] +=dp[i][j][k][l];
                        dp[i+1][k][l][m] %=MOD;
                    }
                }
            }
        }
    }
    ll ans=0;
    rep(i,4){
        rep(j,4){
            rep(k,4){
                ans +=dp[n][i][j][k];
                ans %=MOD;
            }
        }
    }
    cout <<ans<<endl;
    return 0;
}


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

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

typedef long long ll;

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

int main(){
    ll x,k,d;
    cin>>x>>k>>d;

    if(x<0)x=abs(x);

    if(k<=x/d){
        cout<<abs(x-d*k)<<endl;
        return 0;
    }

    ll X=x-(x/d)*d;
    k-=x/d;

    if(k%2==0)cout<<X<<endl;
    else cout<<abs(X-d)<<endl;

}


Measured memory_bytes: 3676
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		for( int i=1; i<=N; i++ ){
			if( i*108/100==N ){
				System.out.println(i);
				break;
			}
			if( i*108/100>N ){
				System.out.println(":(");
				break;
			}
		}
	}
}


Measured memory_bytes: 23252
import java.util.*;
import java.util.stream.Collectors;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        final int N=scanner.nextInt();
        int min=Integer.MAX_VALUE;
        for(int A=1;A<N/2+1;A++){
            int current=func(A)+func(N-A);
            if(min>current){
                //System.out.println("A="+A+",min="+min+",current="+current);
                min=current;
            }
        }
        System.out.println(min);

    }
    public static int func(int A){
        int result=0;
        while(true){
            result+=A-A/10*10;
            A=A/10;
            if(A==0) break;
        }
        return  result;
    }
}

Measured memory_bytes: 23252
# 2020/04/25
# AtCoder Beginner Contest 059 - C

# Input
n = int(input())
a = list(map(int,input().split()))

# Calc
ans = 10**9
for i in range(-100, 101, 1):
    wkval = 0
    for j in range(n):
        wkval = wkval + (a[j] - i) ** 2
    
    ans = min(ans, wkval)

# Output
print(ans)


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){

	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

// gcd(a,b)
int gcd(int a,int b){
	int ret;
	ret = (b == 0) ? a : gcd(b, a % b);
	return ret;
}

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

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[]){
	int n,a;
	scanf("%d %d",&n,&a);
	printf("%d\n",n * n - a);
	return 0;
}


Measured memory_bytes: 128
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

use std::collections::BinaryHeap;
use std::collections::HashSet;

fn main() {
    let (N, Q) = get!(usize, usize);
    let STX = get!(i64, i64, i64; N);
    let D = get!(i64; Q);

    let INF: i64 = 1000000000000000;

    // 各時間帯について、その時間帯に出発すると影響を受ける工事を前もって求める
    // 前もって求めた時間帯→工事を用いて、各クエリに回答する
    let mut C = vec!();
    for (s, t, x) in STX {
        C.push((s - x, x, 1));
        C.push((t - x, x, 0));
    }
    C.sort();
    let mut q = BinaryHeap::new();
    let mut R = HashSet::new();
    let mut u = Vec::new();
    let mut v = Vec::new();
    q.push(-INF);
    for (t, x, k) in C {
        let p = -q.peek().unwrap();
        if k == 1 {
            if x < p {
                u.push(t);
                v.push(p);
            }
            if R.contains(&x) {
                R.remove(&x);
            } else {
                q.push(-x);
            }
        } else {
            R.insert(x);
            if x == p {
                u.push(t);
                v.push(p);
            }
            while R.contains(&-q.peek().unwrap()) {
                R.remove(&-q.pop().unwrap());
            }
        }
    }
    u.push(INF);
    v.push(INF);
    let mut Y = Vec::new();
    let mut i = 0;
    for d in D {
        while u[i] <= d {
            i += 1;
        }
        Y.push(v[i]);
    }

    for y in Y {
        if y == INF {
            println!("-1");
        } else {
            println!("{}", y)
        }
    }
}


Measured memory_bytes: 26316
#include <stdio.h>
int main()
{
    char s1[200],s2[200];
    int i,j,c=0;
    scanf("%s",s1);
    scanf("%s",s2);
    int b=strlen(s2);
    for(i=0,j=b-1;s1[i]!='\0';i++,j--)
    {
        if(s1[i]!=s2[j])
            c=1;
    }
    if(c==0)
        printf("YES\n");
    else if(c==1)
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main(){
	long long x,a,b,ans;
	cin >> x;
	a=(x/500)*1000;
	b=((x%500)/5)*5;
	ans=a+b;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fe(i,a,b) for(ll i=a;i<=b;i++)

vector< vector<int>> adj;
vector<int> dp;

int dfs(int u)
{
  if(dp[u]!=-1)
    return dp[u];
  
  if(adj[u].size()==0)
    return dp[u] = 0;

  int k = 0;

  for(auto v : adj[u])
  { 
   k = max(k,dfs(v));
  }
  
 return dp[u] = k + 1;
}

int main()
{  
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  
  int n=0,m=0,ans=0, x=0,y=0; 
  cin>>n>>m;

  adj.resize(n+1);
  dp.resize(n+1,-1);
  

  fe(i,1,m)
   { 
    cin>>x>>y;
    adj[x].push_back(y);
   }
  
  fe(i,1,n)
   {
    ans = max(ans,dfs(i));
   }

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


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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;




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

    int N; cin >> N;
    cout << (N + 1) / 2 << endl;
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  int ls,lr = 0;
  ls = (S.at(0) - ASCIItoNum) * 10  + (S.at(1) - ASCIItoNum);
  lr = (S.at(2) - ASCIItoNum) * 10  + (S.at(3) - ASCIItoNum);
  
  bool isYYMM = false;
  bool isMMYY = false;
  
  if((1 <= lr) && (lr <= 12)) isYYMM = true;
  if((1 <= ls) && (ls <= 12)) isMMYY = true;
  
  if(isYYMM && isMMYY){
  	cout << "AMBIGUOUS" << endl;
  }else if(isYYMM && !(isMMYY)){
	cout << "YYMM" << endl;
  }else if(!(isYYMM) && isMMYY){
  	cout << "MMYY" << endl;
  }else{
  	cout << "NA" << endl;
  }

  return 0;
}

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

int main() {
	int num[10000] = {};
	int sa = 0, sen = 0;
	int max = 0, count = 0;
	std::cin >> num[0] >> num[1] >> num[2];
	if (num[0] < num[1]) std::swap(num[0], num[1]);
	if (num[1] < num[2]) std::swap(num[1], num[2]);
	if (num[0] < num[1]) std::swap(num[0], num[1]);
	sa = (num[0] - num[1]) + (num[0] - num[2]);
	if (sa % 2 == 0) {
		std::cout << sa / 2 << std::endl;
	}
	else {
		std::cout << (sa + 3) / 2 << std::endl;
	}
}


Measured memory_bytes: 256
public class Main {
    public static void main(String[] args) {
        var sc = new java.util.Scanner(System.in);
        var x = sc.nextBigInteger();
        var op = sc.next();
        var y = sc.nextBigInteger();
        System.out.println((op.equals("+"))?x.add(y):x.subtract(y));
    }
}

Measured memory_bytes: 35772
H,W=map(int, input().split())
S = tuple(input().rstrip() for _ in range(H))
a=0
d=[(1,0),(-1,0),(0,1),(0,-1)]
lity=[[0 for i in range(W)] for j in range(H)]
lity[0][0]=1
def roop()->None:
  p=[(0,0)]
  while p:
    x,y=p.pop(0)
    for dx,dy in d:
      if 0<=x+dx<H and 0<=y+dy<W and S[x+dx][y+dy]=='.' and lity[x+dx][y+dy]==0:
        p.append((x+dx,y+dy))
        lity[x+dx][y+dy]=lity[x][y]+1
roop()
white=sum(t.count(".") for t in S)
x=lity[-1][-1]
ans = white - x
if 0<x:
  print(ans)
else:
  print(-1)

Measured memory_bytes: 3064
// Problem : D - Card Eater
// Contest : AtCoder Beginner Contest 053
// URL : https://atcoder.jp/contests/abc053/tasks/arc068_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb emplace_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inf LLONG_MAX
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

 vi fact,inv;
void inverse(int n)
{inv.resize(n+1);inv[0]=1;
for(int i=1;i<=n;i++)inv[i]=Pow(fact[i],md-2);}
void factorial(int n)
{fact.resize(n+1);fact[0]=1;
for(int i=1;i<=n;i++)fact[i]=(fact[i-1]*i)%md;}

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

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;cin>>n;
set<int> s;int count=0;
for(int i=0;i<n;i++)
{
	int x;cin>>x;
	if(s.find(x)!=s.end())
	count++;
	else
	s.insert(x);
}
if(count%2==0)
cout<<n-count;
else
cout<<n-(count+1);
}

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


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) { rep(_, n) cout << a[_] << " "; cout << endl; }
#define outp(a, n) { cout << endl; rep(_, n) cout << a[_].F << " " << a[_].S << endl; }
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
#define FIX(a) fixed << setprecision(a)
#define LB(v, n) (int)(lower_bound(all(v), n) - v.begin())
#define UB(v, n) (int)(upper_bound(all(v), n) - v.begin())
ll pow(ll a, int b) {return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
ll nck(int n, int k) { ll ret = 1; rep(i, k) {ret *= n - i; ret /= i + 1; } return ret; } // n <= 60
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }


// tle code

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    string str;
    cin >> str;
    
    int al[26] = {0};
    rep(i, SZ(str)) al[str[i] - 'a']++;
    
    ll ans = 0;
    rep(i, 26) rep3(j, i + 1, 26) {
        ans += (ll)al[i] * al[j];
    }
    
    out(ans + 1);
}



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

namespace ALDS1_3_D {
    class Program {
        static void Main(string[] args) {
            Dictionary<int, Stack<int>> dic = new Dictionary<int, Stack<int>>();
            Stack<KeyValuePair<int, int>> stk = new Stack<KeyValuePair<int, int>>();

            string input = Console.ReadLine();
            int height = 0;
            for (int i = 0; i < input.Length; i++) {
                if (input[i] == '\\') {
                    if (!dic.ContainsKey(height))
                        dic[height] = new Stack<int>();
                    dic[height].Push(i);
                    height--;
                }
                else if (input[i] == '/') {
                    height++;
                    stk.Push(new KeyValuePair<int, int>(height, i));
                }
            }

            List<int> areaList = new List<int>();
            int total = 0;
            int area = 0;
            int from = input.Length;
            while (stk.Count > 0) {
                KeyValuePair<int, int> cur = stk.Pop();
                int upH = cur.Key;
                int upW = cur.Value;

                if (!dic.ContainsKey(upH))
                    continue;

                int downW = upW;
                while (dic[upH].Count > 0) {
                    downW = dic[upH].Pop();
                    if (downW < upW)
                        break;
                }

                if (downW >= upW)
                    continue;

                if (from > downW) {
                    from = downW;
                    if (area != 0) {
                        areaList.Add(area);
                        area = 0;
                    }
                }

                int tempArea = upW - downW;
                total += tempArea;
                area += tempArea;
            }

            if (area != 0)
                areaList.Add(area);

            StringBuilder sb = new StringBuilder();
            sb.AppendLine(total.ToString());
            sb.Append(areaList.Count);
            for (int i = areaList.Count - 1; i >= 0; i--)
                sb.AppendFormat(" {0}", areaList[i]);
            Console.WriteLine(sb);
        }
    }
}

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

int main(void){
    int N = 0;
    char S[100] = "";
    char T[50] = "";
    char TT[100] = "";

    scanf("%d",&N);
    scanf("%s",&S);
    for(int i= 0; i < N/2; i++){
        T[i] = S[i];
    }
    strcat(TT,T);
    strcat(TT,T);
    if(strcmp(TT,S) == 0){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128