akhauriyash/Code-Regression huggingface dataset:
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        h: usize,
        w: usize,
        k: usize,
        c: [Chars; h]
    }

    solve(h, w, k, &c);
}

fn solve(h: usize, w: usize, k: usize, c: &Vec<Vec<char>>) {
    let mut ans = 0;
    for i in 0..(2usize.pow(h as u32)) {
        for j in 0..(2usize.pow(w as u32)) {
            let b_i = format!("{:0wid$b}", i, wid = h);
            let b_i: Vec<char> = b_i.chars().collect();
            let b_j = format!("{:0wid$b}", j, wid = w);
            let b_j: Vec<char> = b_j.chars().collect();

            let mut cnt = 0;
            for x in 0..h {
                for y in 0..w {
                    if b_i[x] == '1' && b_j[y] == '1' {
                        if c[x][y] == '#' {
                            cnt += 1;
                        }
                    }
                }
            }
            if cnt == k {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2220
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<stack>
#include<string.h>
#include<functional>
#include<limits.h>
#define int long long
using namespace std;

int a[100000];
signed main() {
	int b, c, d; cin >> b >> c >> d;
	for (int e = 0; e < b; e++) {
		scanf("%lld", &a[e]);
	}
	int S = 0, G = 10000000000ll;//[S,G)
	while (G - S > 1) {
		int K = (S + G) / 2;
		int sum = 0;
		for (int i = 0; i < 100000; i++) {
			int T = max(a[i] - K*d, 0ll);
			sum += T / (c - d);
			if (T % (c - d))sum++;
		}
		if (sum <= K) {
			G = K;
		}
		else {
			S = K;
		}
	}
	cout << G << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
struct node{
	int key;
	node *next,*prev;
	
};
char name[20];
node *nil;
node *list(int key)
{
	node *cur=nil->next;
	while(cur!=nil&&cur->key!=key)
	{
		cur=cur->next;
	}
	return cur;
}
void init()
{
	nil=(node*)malloc(sizeof(node));
	nil->next=nil;
	nil->prev=nil;
}
void printflist()
{
	node *cur=nil->next;
	int isf=0;
	while(1){
		if(cur==nil)break;
		if(isf++>0)printf(" ");
		printf("%d",cur->key);
		cur=cur->next;
	}
	printf("\n");
}
void deletenode(node *t)
{
	if(t==nil)return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t); 
}
void deletefirst()
{
	deletenode(nil->next);
}
void deletelast()
{
	deletenode(nil->prev);
}
void deletekey(int key)
{
     deletenode(list(key));	
}
void insert(int key)
{
	node *x=(node*)malloc(sizeof(node));
	x->key=key;
	x->next=nil->next;
	nil->next->prev=x;
	nil->next=x;
	x->prev=nil;
}
int main()
{
	int n,key;
	
	cin>>n;
	init();
	for(int i=1;i<=n;i++)
	{
		cin>>name;
		if(name[0]=='i'){
			cin>>key;
			insert(key);
		}
		else
		{
			if(name[6]=='F')
			{
				deletefirst();
			}
			else if(name[6]=='L')
			{
				deletelast();
			}
			else
			{
				cin>>key;
				deletekey(key);
			}
		}
	}
     printflist();
     return 0;
}

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

const int MAX_N = 3000;
const int MAX_T = 3000;

int N, T;
vector<int> As(MAX_N);
vector<int> Bs(MAX_N);

// memo1[i][j] := 0 ~ iでj分以内で食べられる最大値
vector<vector<int> > memo1(MAX_N, vector<int>(MAX_T + 1, -1));
// memo2[i][j] := i ~ T - 1でj分以内で食べられる最大値
vector<vector<int> > memo2(MAX_N, vector<int>(MAX_T + 1, -1));

int dp1(int i, int j) {
    if (memo1[i][j] == -1) {
        if (i == 0) {
            if (j >= As[i]) {
                memo1[i][j] = Bs[i];
            } else {
                memo1[i][j] = 0;
            }
        } else {
            if (j >= As[i]) {
                memo1[i][j] = max(dp1(i-1, j), dp1(i-1, j-As[i]) + Bs[i]);
            } else {
                memo1[i][j] = dp1(i-1, j);
            }
        }
    }
    return memo1[i][j];
}

int dp2(int i, int j) {
    if (memo2[i][j] == -1) {
        if (i == N - 1) {
            if (j >= As[i]) {
                memo2[i][j] = Bs[i];
            } else {
                memo2[i][j] = 0;
            }
        } else {
            if (j >= As[i]) {
                memo2[i][j] = max(dp2(i + 1, j), dp2(i + 1, j - As[i]) + Bs[i]);
            } else {
                memo2[i][j] = dp2(i + 1, j);
            }
        }
    }
    return memo2[i][j];
}

int main() {
    cin >> N >>  T;
    for (int i = 0; i < N; i++) {
        cin >> As[i];
        cin >> Bs[i];
    }
    vector<int> ans(N, -1);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < T; j++) {
            if (i == 0) {
                ans[i] = max(ans[i], Bs[i] + dp2(i + 1, T - 1 - j));
            } else if(i == N - 1) {
                ans[i] = max(ans[i], Bs[i] + dp1(i - 1, j));
            } else {
                ans[i] = max(ans[i], Bs[i] + dp1(i - 1, j) + dp2(i + 1, T - 1 - j));
            }
        }
    }
    int r = ans[0];
    for (int i = 0; i < N; i++) {
        r = max(r, ans[i]);
    }
    cout << r << endl;
}


Measured memory_bytes: 71168
#include<iostream>
using namespace std;
#define MAX 500000
int H,A[MAX+1]; 
void maxHeapify(int i){
	int left=2*i;
	int right=2*i+1;
	int largest;
	if(left<=H&&A[left]>A[i])
		largest=left;
	else
		largest=i;
	if(right<=H&&A[largest]<A[right])
		largest=right;
	
	if(largest!=i){
		swap(A[largest],A[i]);
		maxHeapify(largest);
	} 
} 
void buildMaxHeap(int A[]){
	for(int i=H/2;i>=1;i--){
		maxHeapify(i);
	}
}
int main(){
	cin>>H;
	for(int i=1;i<=H;i++){
		cin>>A[i];
	}
	buildMaxHeap(A);
	for(int i=1;i<=H;i++){
		cout<<" "<<A[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 5032
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


k = int(input())

ret = 0

my_dict = dict()

for i in range(1, k+1):
    for j in range(1, i+1):
        for l in range(1, j+1):
            if i == j and j == l:
                ret += gcd_list([i, j, l])
            elif i != j and j != l:
                ret += 6 * gcd_list([i, j, l])
            else:
                ret += 3 * gcd_list([i, j, l])


print(ret)


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

struct data
{
  int input;
  int ind;
};

int main()
{
  int n;
  std::cin >> n;
  std::vector<int> a(n);
  std::vector<int> b(n);
  for(size_t i = 0; i < n; i++) std::cin >> a[i], --a[i];
  for(size_t i = 0; i < n; i++) b[a[i]] = i;
  for(size_t i = 0; i < n; i++) std::cout << ++b[i] << " " << std::endl;; 
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

ll n;

int solve();

int main()
{
    cin >> n;
    cout << solve() << endl;
    return 0;
}

int solve(){
    ll res=0;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            ll now=0;
            while(n%i==0){
                now++;
                n/=i;
            }
            ll cnt=1;
            while(cnt<=now){
                now -= cnt;
                cnt++;
                res++;
            }
        }
    }
    if(n!=1) res++;
    return res;
}

Measured memory_bytes: 3632
n = int(input())
a = list(map(int, input().split()))

nums = [0]*(max(a)+1)
for i in a: nums[i] += 1

if len(nums) <= 2:
  print(sum(nums))
  exit()
  
ans = 0
for i in range(1,max(a)):
  if ans < nums[i-1] + nums[i] + nums[i+1]:
    ans = nums[i-1] + nums[i] + nums[i+1]

print(ans)

Measured memory_bytes: 20788
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

vector<vector<int>> to(100000);
vector<int> cnt(100000, 0);
vector<bool> vis(100000, false);
int n, k;
ll ans;
ll mod = 1000000007;
void dfs(int v, int p = -1){
    vis[v] = true;
    if(p != -1)cnt[v]--;
    for(int t : to[v]){
        if(vis[t])continue;
        int m = k - (to[v].size() + 1 - cnt[v]);
        ans *= max(m, 0);
        ans %= mod;
        cnt[v]--;
        dfs(t, v);
    }
}

int main() {
    cin >> n >> k;
    rep(i, n - 1){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i, n)cnt[i] = to[i].size();
    ans = k;
    dfs(0);
    cout << ans << endl;
}

Measured memory_bytes: 10752
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).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;;) => {
        {
            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;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!();

    let mut ans = "".to_string();
    for (i, c) in s.chars().enumerate() {
        if i % 2 == 0 {
            ans.push(c);
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 4352
class PriorityQueue
  def initialize(array = [])
    @data = []
    array.each { |a| push(a) }
  end

  def total
    @data.sum
  end

  def push(element)
    @data.push(element)
    bottom_up
  end

  def pop
    if size == 0
      nil
    elsif size == 1
      @data.pop
    else
      min = @data[0]
      @data[0] = @data.pop
      top_down
      min
    end
  end

  private

  def swap(i, j)
    @data[i], @data[j] = @data[j], @data[i]
  end

  def size
    @data.size
  end

  def parent_idx(target_idx)
    (target_idx - (target_idx.even? ? 2 : 1)) / 2
  end

  def bottom_up
    target_idx = size - 1
    return if target_idx == 0

    parent_idx = parent_idx(target_idx)
    while @data[parent_idx] < @data[target_idx]
      swap(parent_idx, target_idx)
      target_idx = parent_idx
      break if target_idx == 0

      parent_idx = parent_idx(target_idx)
    end
  end

  def top_down
    target_idx = 0

    # child がある場合
    while has_child?(target_idx)

      a = left_child_idx(target_idx)
      b = right_child_idx(target_idx)

      c = if @data[b].nil?
            a
          else
            @data[a] >= @data[b] ? a : b
          end

      if @data[target_idx] < @data[c]
        swap(target_idx, c)
        target_idx = c
      else
        return
      end
    end
  end

  # @param Integer
  # @return Integer
  def left_child_idx(idx)
    (idx * 2) + 1
  end

  # @param Integer
  # @return Integer
  def right_child_idx(idx)
    (idx * 2) + 2
  end

  # @param Integer
  # @return Boolent
  def has_child?(idx)
    ((idx * 2) + 1) < @data.size
  end
end

N, M = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

pq = PriorityQueue.new(a)
M.times do
  x = pq.pop
  x /= 2
  pq.push x
end
puts pq.total


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<ll> R,L,U,D,X,Y;
vector<ll> cand;
ll ret;

void hoge(vector<ll>& V) {
	if(V.size()) {
		sort(ALL(V));
		int x=V[0];
		int y=V.back();
		V.clear();
		V={x,y};
		
	}
}

void hogev(vector<ll>& A,vector<ll>& B,int d) {
	if(A.size()&&B.size()) {
		cand.push_back(abs(A[0]-B[0])/d);
		cand.push_back(abs(A[0]-B[1])/d);
		cand.push_back(abs(A[1]-B[0])/d);
		cand.push_back(abs(A[1]-B[1])/d);
	}
}

void test(pair<ll,ll> X, pair<ll,ll> Y) {
	if(X.first<=Y.first&&X.second<=Y.second) return;
	if(X.first>=Y.first&&X.second>=Y.second) return;
	if(X.first>Y.first) swap(X,Y);
	ll d1=Y.first-X.first;
	ll d2=Y.second-X.second;
	
	
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	FOR(i,N) {
		cin>>x>>y>>s;
		x*=2;
		y*=2;
		if(s=="L") {
			L.push_back(x);
			Y.push_back(y);
		}
		if(s=="R") {
			R.push_back(x);
			Y.push_back(y);
		}
		
		if(s=="U") {
			U.push_back(y);
			X.push_back(x);
		}
		if(s=="D") {
			D.push_back(y);
			X.push_back(x);
		}
	}
	hoge(L);
	hoge(R);
	hoge(U);
	hoge(D);
	hoge(X);
	hoge(Y);
	
	cand.push_back(0);
	cand.push_back(1<<30);
	
	hogev(L,X,1);
	hogev(R,X,1);
	hogev(L,R,2);
	hogev(U,Y,1);
	hogev(D,Y,1);
	hogev(U,D,2);
	sort(ALL(cand));
	vector<pair<ll,ll>> V;
	ret=1LL<<60;
	FORR(c,cand) {
		ll x1=1LL<<40,x2=-1LL<<40;
		ll y1=1LL<<40,y2=-1LL<<40;
		if(L.size()) x1=min(x1,L[0]-c),x2=max(x2,L[1]-c);
		if(R.size()) x1=min(x1,R[0]+c),x2=max(x2,R[1]+c);
		if(X.size()) x1=min(x1,X[0]+0),x2=max(x2,X[1]+0);
		if(U.size()) y1=min(y1,U[0]+c),y2=max(y2,U[1]+c);
		if(D.size()) y1=min(y1,D[0]-c),y2=max(y2,D[1]-c);
		if(Y.size()) y1=min(y1,Y[0]+0),y2=max(y2,Y[1]+0);
		V.push_back({x2-x1,y2-y1});
		ret=min(ret,(x2-x1)*(y2-y1));
	}
	
	FOR(i,V.size()-1) test(V[i],V[i+1]);
	_P("%.12lf\n",ret/4.0);
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 2160
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val r = sc.nextInt()
    val g = sc.nextInt()
    val b = sc.nextInt()
    val n = sc.nextInt()

    val ret = (0..n).map { i ->
        (0..n).map { j ->
            if (n - r * i - g * j >= 0) {
                if ((n - r * i - g * j) % b == 0) 1 else 0
            } else 0
        }.sum()
    }.sum()

    println(ret)
}

Measured memory_bytes: 68880
using System;

namespace A___Ball_Distribution
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var k = int.Parse (input[1]);
            if (k == 1)
                Console.WriteLine (0);

            else
                Console.WriteLine (n - k);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;
#define reps(i,s,n) for(int (i) = (s); (i) < (n); ++(i))
#define rep(i,n) reps(i,0,n)
using ll = long long;

struct data_t{
    ll num;
    ll rank;
    bool operator<(const data_t& right) const{
        return num == right.num ? rank < right.rank : num < right.num; 
    }
};

int main(){
    ll n,k;
    cin >> n >> k;
    vector<data_t> dat2(n);

    rep(i,n){
        cin >> dat2[i].num >> dat2[i].rank;
    }

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

    ll sum = 0;
    rep(i,n){
        sum += dat2[i].rank;
        //cout << "sum:" << sum << " k:" << k << endl;; 
        if(sum >= k){
            cout << dat2[i].num << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 1792
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
n = ni()
if n==1:
    print(1)
    exit()
xy = []
for i in range(n):
    xy.append(tma())
co = collections.Counter()

for i in range(n):
    for j in range(n):
        if i==j:
            continue
        x1,y1 = xy[i]
        x2,y2 = xy[j]
        co[(x2-x1,y2-y1)] +=1

ans = 10**9
for num in co.values():
    ans = min(ans,n-num)
print(ans)


Measured memory_bytes: 9696
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

string align_digit(int n) {
    string res = to_string(n);
    while (res.size()<6) {
        res = '0'+res;
    }
    return res;
}

int main() {
    int N,M; cin>>N>>M;
    pair<int,pair<int,int>> P[M];
    REP(i,M) {
        cin>>P[i].first>>P[i].second.first;
        P[i].second.second = i;
    }
    sort(P,P+M);
    int pre = P[0].first;
    int cnt = 1;
    REP(i,M) {
        if (pre!=P[i].first) {
            cnt = 1;
        }
        P[i].second.first = cnt;
        pre = P[i].first;
        cnt++;
    }
    Pi ans[M];
    REP(i,M) {
        ans[P[i].second.second].first = P[i].first;
        ans[P[i].second.second].second = P[i].second.first;
    }
    REP(i,M) cout<<align_digit(ans[i].first)<<align_digit(ans[i].second)<<endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
 
int N, sum = 0;
vector<int> S(101, 0);
bitset<100001> bit;

int main(void){
	
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) scanf("%d", &S[i]), sum += S[i];
	
	if(sum % 10 == 0){
	    while(sum % 10 == 0){
	        auto itr = min_element(S.begin(), S.end());
	        if(*itr == INT_MAX) { printf("0\n"); return 0; }
	        else if((sum - *itr) % 10 == 0) *itr = INT_MAX;
	        else sum -= *itr;
	    }
	}
	printf("%d\n", sum);
	
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  string s;
  cin >> s;
  int c=0;
  rep(i,0,s.size()-1){
    if(s.at(i)=='A' && s.at(i+1)=='C') c++;
  }
  if(c==0) co("No");
  else co("Yes");
  
  
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

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

    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n;) {
        int cnt = 0;
        for (int j = 1; j <= i;) {
            if (i % j == 0) cnt++;
            j += 2;
        }
        if (cnt == 8) ans++;
        i += 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
 int a,b,total1,total21,total22,stotal;
 scanf("%d" "%d",&a,&b);
 total1=a*b;
 total21=a*2;
 total22=b*2;
 stotal=total21+total22;
 printf("%d %d\n",total1,stotal);
return 0;
}

Measured memory_bytes: 1784
input_lines = readlines
length = input_lines.length
 
i = 0
while i < length
    input_lines[i] = input_lines[i].chomp.to_i
    i += 1
end

 
if (input_lines[4] -input_lines[0]) > input_lines[5]
print ":("
else
  print "Yay!"
end

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

using namespace std;

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

const int INF = 1000000000; //
const ll LINF = (ll) 4000000000000000000; //
const ll MOD = (ll) 1000000007; //
const double PI = 3.1415926535898; //

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;

    return 0;
}


Measured memory_bytes: 764
#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 x;
	int ans;
	cin >> x;
	if (x >= 400 && x <= 599)
		ans = 8;
	else if (x >= 600 && x <= 799)
		ans = 7;
	else if (x >= 800 && x <= 999)
		ans = 6;
	else if (x >= 1000 && x <= 1199)
		ans = 5;
	else if (x >= 1200 && x <= 1399)
		ans = 4;
	else if (x >= 1400 && x <= 1599)
		ans = 3;
	else if (x >= 1600 && x <= 1799)
		ans = 2;
	else if (x >= 1800 && x <= 1999)
		ans = 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000009;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

char in[200050];
int sum[200050];
int main() {
	int N, i, j;
	scanf("%d %s", &N, in + 1);
	for (i = 1; i <= N; i++) sum[i] = sum[i - 1] + (int)(in[i] == '#');

	int ans = INF;
	for (i = 0; i <= N; i++) {
		int c = sum[i] + (N - i - (sum[N] - sum[i]));
		ans = min(ans, c);
	}
	return !printf("%d\n", ans);
}

Measured memory_bytes: 1280
n = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for _ in range(n):
    s = input()
    if s == 'AC': ac += 1
    if s == 'WA': wa += 1
    if s == 'TLE': tle += 1
    if s == 'RE': re += 1

print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))


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

using namespace std;

const int MAX_N = 200000;

int K, N;


int A[MAX_N];
int gap[MAX_N];

int solve()
{
    for(int i = 0; i < N-1; i++) gap[i] = A[i+1] - A[i];
    gap[N-1] = K - A[N-1] + A[0];
    int ret = 0;
    int max = 0;
    for(int i = 0; i < N; i++) 
    {
        ret += gap[i];
        if(gap[i] > max) max = gap[i];
    }
    return ret - max;
}

int main()
{
    cin >> K >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    
    cout << solve() << endl;

    return EXIT_SUCCESS;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef pair<pl, ll> ppl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, k, n) for(ll i = ll(k); i <= ll(n); i++)
#define rep3(i, n, k) for(ll i = ll(n); i >= ll(k); i--)
#define all(v) (v).begin(), (v).end()
ll mod(ll a, ll b) {if(b == 0) return 0; return (a % b + b) % b;}
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 2e5;
const char newl = '\n';

vl parent(MAX), depth(MAX);
 
ll find(ll x) {if(parent[x]==x) return x; return parent[x] = find(parent[x]);}
 
void unite(ll x, ll y) {
  x = find(x);
  y = find(y);
  if (x==y) return;
  
  if(depth[x] < depth[y]) {
    parent[x] = y;
  }else {
    parent[y] = x;
    if(depth[x] == depth[y]) depth[x]++;
  }
}

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

  ll n, m;
  cin >> n >> m;

  rep(i, n) parent[i] = i;

  ll a, b;
  rep(i, m) {
    cin >> a >> b;
    a--; b--;
    unite(a, b);
  }

  vb is_parent(n, 0);
  rep(i, n) is_parent[find(i)] = 1;
  ll ans = -1;
  rep(i, n) if(is_parent[i]) ans++;
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 6228
#include <iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    int sum = 0;
    int a[n];
    for(int i = 0; i< n; i++){
        cin >> a[i];
    }
    
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            sum += a[i] * a[j];
        }
        
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <math.h>
using namespace std;

int main() {
    int n;
    cin>>n;
    vector<int>l(n);
    for(int i=0;i<n;i++)cin>>l[i];
    sort(l.begin(),l.end());
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]!=l[j]){
                    if(l[j]!=l[k]){
                        if(l[i]+l[j]>l[k] && l[j]+l[k]>l[i] && l[k]+l[i]>l[j])ans++;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
X = int(input())

if 400 <= X <= 599:
    print(8)
if 600 <= X <= 799:
    print(7)
if 800 <= X <= 999:
    print(6)
if 1000 <= X <= 1199:
    print(5)
if 1200 <= X <= 1399:
    print(4)
if 1400 <= X <= 1599:
    print(3)
if 1600 <= X <= 1799:
    print(2)
if 1800 <= X <= 1999:
    print(1)

Measured memory_bytes: 9188
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    int *t;
    int *x;
    int *y;
    int now_x=0;
    int now_y=0;
    int now=0;
    int temp;
    t = new int[N];
    x = new int[N];
    y = new int[N];
    for(int i=0;i<N;i++){
        cin >> t[i] >> x[i] >> y[i];
        temp = abs(x[i]-now_x)+abs(y[i]-now_y)-abs(t[i]-now);
        //cout << temp << endl;
        if((temp%2)!=0||temp>0){
            cout << "No" << endl;
            return 0;
        }
        now_x = x[i];
        now_y = y[i];
        now = t[i];
    }
    cout << "Yes" <<endl;
    return 0;
}

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

int main()
{
  int n;

  while(1){
    cin>>n;
    if(n==0)break;
    int sum[7]={};
    for(int i=0;i<n;i++){
      int m;
      cin>>m;
      if(m<10)sum[0]++;
      else if(m<20)sum[1]++;
      else if(m<30)sum[2]++;
      else if(m<40)sum[3]++;
      else if(m<50)sum[4]++;
      else if(m<60)sum[5]++;
      else sum[6]++;
    }
    for(int i=0;i<7;i++)cout<<sum[i]<<endl;
  }
  
  return 0;
}

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

int main(){
	int n , a[100]={0};
	cin>>n;
	for(int i=0 ; i<n ; i++){
		cin >> a[i] ;
	}
	for(int i=n-1 ; i>0 ; i--){
		cout  << a[i] << " ";
	}
		cout << a[0];
		cout << endl;
	return 0;
}

Measured memory_bytes: 1164
import sys
import math
input = sys.stdin.readline
ceil = math.ceil

def main():
    def isok(z,val):##適宜変更
        return (z-val<=2*d)
    def bisect(ls,val): ##valの関数isok(x,val)がTrueとなる一番右のindex を返す 全部Falseなら-1
        ok = -1
        ng = len(ls)
        idx = (ok+ng)//2
        while ng-ok>1:
            num = ls[idx]
            if isok(num,val):
                ok = idx
            else:
                ng = idx
            idx = (ok+ng)//2
        return ok ##一番右のTrueのindex  Trueの個数はok+1こ

    n,d,a = map(int,input().split())
    mon = []
    for i in range(n):
        x,h = map(int,input().split())
        mon.append((x,h))
    mon.sort()
    keys = [ls[0] for ls in mon] #bisect用の配列

    damage = [0]*(n+1)
    ans = 0
    for i in range(n):
        x,h = mon[i]
        res = h-damage[i]
        if res>0:##体力が残ってたら
            c = ceil(res/a)
            ans+=c
            idx = bisect(keys,x) ##爆風が届くぎりぎりの位置
            if idx==-1:continue
            damage[i] +=a*c
            damage[idx+1] -=a*c
        damage[i+1] += damage[i]
    print(ans)
if __name__=="__main__":
    main()


Measured memory_bytes: 84364
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;

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

int main(){
  ll N, M;
  cin>>N>>M;
  vector<ll> A(M);
  vector<bool> Num(10, false);
  vector<ll> W={6,2,5,5,4,5,6,3,7,6};
  rep(i, M){
    cin>>A[i];
    Num[A[i]]=true;
  }
  vector<string> D(N+1);
  rep(i, N){
    //cout<<"turn"<<i+1<<endl;
    for(ll j=1; j<=9; j++){
      if(!(Num[j]))continue;
      if(i+1-W[j]<0)continue;
      if(i+1-W[j]==0||D[i+1-W[j]].size()!=0){

        char X=(char)((int)'0'+j);
        string S=D[i+1-W[j]]+X;
        //cout<<X<<" "<<S<<endl;
        if(S.size()<D[i+1].size())continue;
        if(S.size()>D[i+1].size()){
          D[i+1]=S;
          continue;
        }
        D[i+1]=max(D[i+1], S);
      }
    }
    //cout<<"D="<<D[i+1]<<endl;
  }
  cout<<D[N]<<endl;
}

Measured memory_bytes: 32052
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>
#include <sstream>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}

	int A, B;
	std::cin >> A >> B;

	int result = 0;
	for (int i = A; i <= B; ++i) {
		std::stringstream ss;
		ss << i;
		std::string s;
		ss >> s;
		std::string t = s;
		std::reverse(t.begin(), t.end());
		if (s == t) {
			++result;
		}
	}
	
	std::cout << result << "\n";
}


Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = s, i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = s; i < (n); ++i)
#define VFORS(i, s, n) for(int i = s; i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = s, i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = s, i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());

using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;
using VD = vector<double>;

const int MOD = 1000000007;
const int INF = 1000000000;

template<class T>bool chmax(T &a, const T &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T>bool chmin(T &a, const T &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}

int main(){
    int a, b; cin >> a >> b;
    int cnt = 0;
    FORS(i, a, b){
        if(((i%10)==(i/10000%10)) && ((i/10%10)==(i/1000%10)))
            ++cnt;
    }
    cout << cnt << "\n";
    return 0;
}


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

int main(){
  int N,K;
  K=0; 
  cin >>N;
  for(int i=1;i<N+1;i++){
   if((0<i)&&(i<10)||(99<i)&&(i<1000)||(9999<i)&&(i<100000)){
    K++;
   }
   }

  cout << K<<endl;
  return 0;
}

  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    ll n,m;
    cin>>n>>m;
    ll ans = 0;
    if(n>=3 && m>=3){
        ans+=(n-2)*(m-2);
    }else if(n==1 || m==1){
        if(n>=3 || m>=3) ans+=max(n,m)-2;
        if(max(n,m)==1) ans = 1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N,K;
    cin >> N >> K;
    int ans=0;
    while(N>0){
        N/=K;
        ans++;
    }
    cout << ans << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x1,y1,x2,y2,p,q;
  cin >> x1 >> y1 >> x2 >> y2;
  p=x2-x1;
  q=y2-y1;
  cout << x2-q <<" "<< y2+p <<" "<< x1-q <<" "<< y1+p << endl;
}


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

int main() {
    int N, T, A;
    cin >> N >> T >> A;
    vector<int> H(N);
    rep(i, N) {
        cin >> H.at(i);
    }

    float min_diff = 10000000;
    int min_index;

    vector<float> temp(N);
    rep(i, N) {
        float temp = T - H.at(i) * 0.006;
        float diff = abs(temp - A);
        if (min_diff > diff) {
            min_diff = diff;
            min_index = i;
        }
    }

    cout << min_index + 1 << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int dp[32][52][10],C,D,W,X,e[16][32],f[16][32];
int solve(int d,int w,int p){
	if(w>W)return -999999999;
	if(p>X)return -999999999;
	if(d==D)return 0;
	if(dp[d][w][p]>=0)return dp[d][w][p];
	int maxn=solve(d+1,w,p);
	for(int i=0;i<C;i++){
		for(int j=i;j<C;j++){
			bool OK=false;for(int k=i;k<=j;k++){if(e[k][d]==0)OK=true;}
			if(OK==true)continue;
			int s=0;for(int k=i;k<=j;k++)s+=e[k][d];
			int t=0;for(int k=i;k<=j;k++)t+=f[k][d];
			int u=0;if(j-i>=1)u=1;
			maxn=max(maxn,solve(d+1,w+t,p+u)+s);
		}
	}
	dp[d][w][p]=maxn;
	return maxn;
}
int main(){
	while(true){
		cin>>C>>D>>W>>X;if(C+D+W+X==0)break;
		for(int i=0;i<=D;i++){for(int j=0;j<=W;j++){for(int k=0;k<=X;k++)dp[i][j][k]=(-1LL<<30);}}
		for(int i=0;i<C;i++){for(int j=0;j<D;j++)cin>>e[i][j];}
		for(int i=0;i<C;i++){for(int j=0;j<D;j++)cin>>f[i][j];}
		cout<<solve(0,0,0)<<endl;
	}
}

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	ans := int(1e18)
	for k := 0; k < 2; k++ {
		for i := 1; i < h; i++ {
			a := i * w

			b := ((h - i) / 2) * w
			c := (h * w) - (a + b)
			s := max(a, max(b, c)) - min(a, min(b, c))
			ans = min(ans, s)

			b = (h - i) * (w / 2)
			c = (h * w) - (a + b)
			s = max(a, max(b, c)) - min(a, min(b, c))
			ans = min(ans, s)
		}
		h, w = w, h
	}
	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long

using namespace std;

string s;

int main()
{
    ios::sync_with_stdio(0);
    cin >> s;
    for (int i=0;i<s.length();i++)
    {
        if (s[i] == '7')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

#define sp <<" "
#define el <<"\n"
#define S second
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define obit __builtin_popcount
#define pof pop_front
#define For(i,a,n) for(i=a;i<n;i++)
#define all(ar) ar.begin(),ar.end() 
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned short int us;
typedef short int ss;
typedef long double ld;
const ll mod = 1000000007;



int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    /*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    //*/
    int i,n,tn = 0,mn = 10000, ntn = 0;
    cin>>n;
    For(i,0,n){
        int x; cin>>x;
        if(x % 10 == 0) tn += x;
        else{
            ntn += x;
            if(x < mn){
                mn = x;
            }
        }
    }
    if(ntn % 10 == 0){
        ntn -= mn; ntn = max(ntn,0);
    }
    tn += ntn;
    if(tn % 10 == 0) cout<<0;
    else cout<<tn;
    return 0;
}

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

int main(void) {	
	int N;
	scanf("%d", &N);
	char S[10001];
	scanf("%s", &S);
	int i = 0;
	while (S[i] != NULL) {
		S[i] += N;
		if (S[i] > 'Z') S[i] -= 26;
		printf("%c", S[i]);
		i++;
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
food = 0
manzoku = 0
bonus = 0
before = 10*3
ans = 0
for i in range(n):
    food = a[i]
    manzoku = b[food-1]
    if food == before+1:
        bonus = c[food-2]
        ans += manzoku + bonus
    else:
        ans += manzoku
    before = food
print(ans)

Measured memory_bytes: 9148
function Main(input) {
  input = input.trim();
  input = input.split("");
  var output = input.slice().reverse();
  var count = input.length;
  for(var i=0; i<input.length;i++){
    if(input[i]==output[i]){
      count--;
    }
  }
  console.log(count/2);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
  int n, x;
  std::cin >> n >> x;

  std::vector<int> donuts(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    std::cin >> donuts.at(i);
    sum += donuts.at(i);
  }
  int remaining = x - sum;
  int min = *std::min_element(donuts.begin(), donuts.end());
  std::cout << n + remaining / min << std::endl;
}


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

int main() {
    int n,k;
    cin>>n>>k;
    vector<int>arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i];
    sort(arr.begin(),arr.end());
    long long ans=0;
    for(int i=0;i<(n-k);i++)
        ans+=arr[i];
    cout<<ans;    
	return 0;
}

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

long long *a{};
int n, k;

bool need(long long, long long, int, int);

int main()
{
	scanf("%d%d", &n, &k);
	a = new long long[n];
	for (int i = 0; i < n; i++) scanf("%lld", a + i);
	std::sort(a, a + n, std::greater<long long>());
	int need_count{};
	for (int i = 0; i < n; i++)
	{
		if (a[i] >= k || need(k - a[i], k, n - 1, i))
			need_count++;
	}
	printf("%d\n", n - need_count);

	delete[] a;
	return 0;
}

bool need(long long left, long long right, int a_index, int ignore)
{
	if (left <= 0 && right > 0) return true;
	if (a_index == -1 || right <= 0) return false;

	if (a_index == ignore)
		return need(left, right, a_index - 1, ignore);
	// 連結なら連結したやつを渡す
	if (right - a[a_index] >= left)
		return need(left - a[a_index], right, a_index - 1, ignore);
	// 非連結なら両方
	return need(left - a[a_index], right - a[a_index], a_index - 1, ignore) || need(left, right, a_index - 1, ignore);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>

#define pb push_back
#define int long long
#define ld long double
using namespace std;
const int M = 1000000007;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> A(n);
    for (int i = 0; i < n; i++) cin >> A[i];
    int c = 1, ans = 0;
    for (int i = 1; i < n; i++) {
        if (A[i] == A[i - 1]) {
            c++;
        } else {
            ans += c / 2;
            c = 1;
        }
    }
    ans += c / 2;
    cout << ans << '\n';
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll K, A, B; cin >> K >> A >> B;
  for (ll i = A; i <= B; i++) {
    if (i % K == 0) {
      cout << "OK\n";
      return 0;
    }
  }
  cout << "NG\n";

  return 0;
}



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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

const int mod = 1000000007;

class CumulativeSum {
    vector<ll> numbers;
    vector<ll> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, ll value) {
        numbers[i] = value;
    }

    ll getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return 0;
        return sums[i];
    }

    ll getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void calculate() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];

    CumulativeSum cs(n);
    rep(i, n) cs.set(i, numbers[i]);
    cs.calculate();

    set<ll> sums;

    for (ll a = 0; a < n; a++) {
        for (ll b = a; b < n; b++) {
            sums.insert(cs.getSectionSum(a, b));
        }
    }

    for (ll i = 0; i < 64; i++) {
        ll a = 0;
        ll j = 64ll - i - 1;

        for (ll l : sums) {
            bool b = (l >> j) & 1;
            if (b) a++;
        }

        if (a >= k) {
            set<ll> sums2;
            ll mask = (1ll << (j));
            for (ll l : sums) if (l & mask)sums2.insert(l);
            sums = sums2;
        }
    }

    ll ans = (1ll << 63ll) - 1;

    for (ll l : sums) ans = (ans & l);


    cout << ans << endl;


}


Measured memory_bytes: 29056
n=gets.to_i
activities=n.times.map{gets.split.map(&:to_i)}
dp=[0,0,0]
activities.each{|a|
  _dp=[0,0,0]
  3.times{|i|
    _dp[i]=a[i]+([*0...3]-[i]).map{|j|dp[j]}.max
  }  
  dp=_dp
}
puts dp.max

Measured memory_bytes: 9596
#include <bits/stdc++.h>
#define int long long
using namespace std;


template<int mod>
struct ModInt{
	int x;

	ModInt() : x(0){}
	ModInt(long long y) : x(y>=0 ? y%mod : (mod-(-y)%mod)){}

	ModInt &operator+=(const ModInt &p){
		if((x+=p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator-=(const ModInt &p){
		if((x+=mod-p.x)>=mod)x-=mod;
		return *this;
	}
	ModInt &operator*=(const ModInt &p){
		x=(int)(1LL*x*p.x%mod);
		return *this;
	}
	ModInt &operator/=(const ModInt &p){
		*this*=p.inverse();
		return *this;
	}

	ModInt operator-() const{return ModInt(-x);}
	ModInt operator+(const ModInt &p) const{return ModInt (*this)+=p;}
	ModInt operator-(const ModInt &p) const{return ModInt (*this)-=p;}
	ModInt operator*(const ModInt &p) const{return ModInt (*this)*=p;}
	ModInt operator/(const ModInt &p) const{return ModInt (*this)/=p;}
	bool operator==(const ModInt &p) const{return x==p.x;}
	bool operator!=(const ModInt &p) const{return x!=p.x;}
	friend ostream &operator<<(ostream &os, const ModInt &p){return os<<p.x;}
	friend istream &operator>>(istream &is,ModInt &a){
		int t;
		is>>t;
		a=ModInt<mod>(t);
		return (is);
	}

	ModInt inverse() const{
		int a=x, b=mod, u=1, v=0, t;
		while(b>0){
			t=a/b;
			a-=t*b;
			swap(a,b);
			u-=t*v;
			swap(u,v);
		}
		return ModInt(u);
	}
	
	ModInt pow(int e) const{
		long long a=1,p=x;
		while(e>0){
			if(e%2==0){p=(p*p)%mod; e/=2;}
			else {a=(a*p)%mod; e--;}
		}
		return ModInt(a);
	}
};

using modint=ModInt<1000000007>;
modint dp[100000+100];

signed main(){
	int N,M; cin>>N>>M;
	set<int> A;
	for(int i=0;i<M;i++){
		int a; cin>>a; A.insert(a);
	}
	dp[0]=1;
	for(int i=0;i<N;i++){
		if(!A.count(i)){
			dp[i+2]+=dp[i];
			dp[i+1]+=dp[i];
		}
		else dp[i]=0;
	}
	cout<<dp[N]<<endl;
}

Measured memory_bytes: 5760