akhauriyash/Code-Regression huggingface dataset:
// C++のテンプレート
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(void){
    int alp[26] = {};
    string w;
    cin >> w;
    for(int i=0;i<w.size();i++){
        alp[w[i]-'a']++;
    }
    bool tf=true;
    for(int i=0;i<26;i++)
        if(alp[i]%2==1){
            tf=false;
            break;
        }
    if(tf)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    ll K; cin >> K;

    const int NMAX = 50;
    vl a(NMAX);
    REP(i, NMAX) a[i] = i;

    ll Q = K / NMAX;
    REP(i, NMAX) a[i] += Q;

    ll R = K % NMAX;
    REP(i,R) {
        int mi = 0;
        FOR(j, 1, NMAX) if (a[j] < a[mi]) mi = j;

        a[mi] += NMAX;
        REP(j,NMAX) {
            if (j != mi) a[j]--;
        }
    }

    cout << NMAX << endl;
    cout << a[0];
    FOR(i, 1, NMAX) cout << " " << a[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;
const ll modP = 1000000007;


int main()
{
	string s,t;
	cin>>s>>t;
	ll ans = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != t[i]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3464
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iomanip>
#include <deque>
#include <unordered_set>


using namespace std;

#define int long long

signed main() {
	int n;
	cin >> n;
	vector <int> v(n + 2, 0);
	for (int i = 1; i <= n; i++) {
		cin >> v[i];
	}
	int sum = 0;
	for (int i = 1; i < n + 2; i++) {
		sum += abs(v[i] - v[i - 1]);
	}
	for (int i = 1; i <= n; i++) {
        int cur = sum;
		if ((v[i] - v[i - 1]) * (v[i] - v[i + 1]) > 0) {
			cur = sum - 2 * min(abs(v[i] - v[i - 1]), abs(v[i] - v[i + 1]));
		}
		cout << cur <<endl;
	}

}


Measured memory_bytes: 2048
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, m, c;
  cin >> n >> m >> c;
  int ans = 0;
  vector<int> b(m);
  for(int i = 0; i < m; i++) cin >> b[i];
  for(int i = 0; i < n; i++) {
    int sum = 0;
    for(int j = 0; j < m; j++) {
      int a;
      cin >> a;
      sum += a * b[j];
    }
    sum += c;
    if(sum > 0) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<cmath>
#include<bitset>
#include<cassert>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
int main()
{
    fast_io;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;

    int res = 0;

    for (int i = 1; i < n; i++)
    {
        int val = n / i;
        if (n % i == 0) val--;
        res += val;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3220
n = int(input())
a = list(map(int,input().split()))
mod = 10**9+7
cnt = [0] * 65
ans = 0
for i in range(61):
    for x in a:
        if (x>>i)%2 == 1:
            cnt[i] +=1
for i in range(65):
    ans += (cnt[i]*(n-cnt[i])*(2**i))%mod
    ans %=mod
print(ans)
    
    

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

using namespace std;

typedef long long LL;

const int N = 100005;

int a[N];
LL c[N], d[N];

int main() {
    int n;
    scanf("%d", &n);

    if (n == 1) {
        printf("YES"); return 0;
    }

    LL s = 0;

    for (int i = 1; i <= n; i++) {
        scanf("%d", a+i);
        s += a[i];
    }

    if (s % (n*LL(n+1)/2) != 0) {
        printf("NO"); return 0;
    }

    s /= (n * LL(n+1) / 2);

    for (int i = 1; i <= n; i++) {
        int b = a[i+1];
        if (i == n) b = a[1];
        {
            LL x = s + a[i] - b;
            if (x < 0 || x % n != 0) {
                printf("NO"); return 0;
            }
            x /= n;
            if (i == n) c[1] += x;
            else c[i+1] += x;
        }
    }

    for (int i = 1; i <= n; i++) {
        d[i] = LL(c[i]) * i + d[i-1];
        c[i] += c[i-1];
    }

    for (int i = 1; i <= n; i++) {
        LL tmp = s + (LL(i) * c[i] - d[i]) + (LL(n+i) * (s-c[i]) - (d[n]-d[i]));
        if (tmp != a[i]) {
            printf("NO"); return 0;
        }
    }

    printf("YES");
}


Measured memory_bytes: 2176
#include <stdio.h>

int main()
{
    int n=0,m[1001]={0},x=0,sum=0,min=0;
    scanf("%d %d",&n,&x);
    for(int i=0;i<n;i++){
	scanf("%d",&m[i]);
	sum=sum+m[i];
	if(i==0 || m[i]<min)
	    min=m[i];
    }

    x=x-sum;
    x=x/min;

    printf("%d\n",n+x);

    return 0;
}



    


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC096
{
    class Program
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int a = input[0];
            int b = input[1];
            int c = input[2];

            string result = "No";

            result = ((a + b) >= c) ? "Yes" : "No";

            Console.WriteLine(result);
            
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13268
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int k = sc.nextInt();

        Deque<Long> deque = new ArrayDeque<>();
        for (long i = 1; i < 10; i++) {
            deque.add(i);
        }

        for (int i = 1; i < k; i++) {
            long v = deque.pop();
            long matubi = v % 10;
            v *= 10;
            switch ((int)matubi) {
                case 0:
                    deque.add(v);
                    deque.add(++v);
                    break;
                case 9:
                    deque.add(v + matubi - 1);
                    deque.add(v + matubi);
                    break;
                default:
                    deque.add(v + matubi - 1);
                    deque.add(v + matubi);
                    deque.add(v + matubi + 1);
                    break;
            }
        }

        System.out.println(deque.pop());
    }
}

Measured memory_bytes: 30420
#include<iostream>
#include<algorithm>
using namespace std;
int o(int a,int b) {
	return a > b;
}
int main() {
	int n,k;
	cin >> n >> k;
	int a[n+1];
	for (int i = 1; i <= n; i++)
    cin>>a[i];
  sort(a+1, a+n+1, o);
	int t = 0;
	for(int i = 1; i <= k; i++)
    t+=a[i];
	cout << t << endl;;
	return 0;
 }


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

int main()
{
	long long n, x, m;
    cin >> n >> x >> m;

    vector<int> mod_kind(m, -1);

    long long buf = x, first, finish;

    vector<int> S;
    mod_kind[buf] = 0;
    S.push_back(buf);
    for (int i = 1; i <= 2 * m; i++)
    {
        buf *= buf;
        buf %= m;

        if(mod_kind[buf] == -1)
        {
            mod_kind[buf] = i;
            S.push_back(buf);
        }
        else
        {
            first = mod_kind[buf];
            finish = i - 1;
            break;
        }
    }

    long long ans = 0;
    if(n >= first)
    {
        for (int i = 0; i < first; i++)
        {
            ans += S[i];
        }
        n -= first;

        buf = 0;
        for (int i = first; i <= finish; i++)
        {
            buf += S[i];
        }
        
        ans += buf * (n / (finish - first + 1));

        for (int i = 0; i < (n % (finish - first + 1)); i++)
        {
            ans += S[first + i];
        }
        
    }
    else
    {
        for (int i = 0; i < n; i++)
        {
            ans += S[i];
        }
    }
    
    cout << ans << endl;
}

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

class Container
{
public:
	void append( pair< int, int > p )
	{
		masterList.push_back( p );
	}
	void cSort()
	{
		sort( masterList.begin(), masterList.end() );
		sortedList.clear();
		vector< pair< int, int > >::iterator itr = masterList.begin();
		while( itr != masterList.end() ){
			vector< pair< int, int > > v;
			int x = itr->first;
			v.push_back( *itr );
			++itr;
			if( itr != masterList.end() && itr->first == x ){
				v.push_back( *itr );
				++itr;
			}
			sortedList.push_back( v );
		}
	}

	int countContainment()
	{
		int result = 0;
		int dp[ 201 ][ 1000 ];
		memset( dp, 0, sizeof(dp) );
		for( int i = 0; i < (int)sortedList.size(); ++i ){
			int r = sortedList[ i ][ 0 ].second;
			for( int j = 0; j < r; ++j ){
				dp[ i + 1 ][ j ] = dp[ i ][ j ];
			}
			for( int j = r; j < 1000; ++j ){
				dp[ i + 1 ][ j ] = max( dp[ i ][ j ], dp[ i ][ r - 1 ] + 1 );
			}
		}

		return dp[ sortedList.size() ][ 1000 - 1 ];
	}

	void cSwap()
	{
		for( int i = 0; i < (int)masterList.size(); ++i ){
			int t = masterList[ i ].first;
			masterList[ i ].first = masterList[ i ].second;
			masterList[ i ].second = t;
		}
	}


	vector< pair< int, int > > masterList;
	vector< vector< pair< int ,int > > > sortedList;
};

int main()
{
	int n, m;

	while( cin >> n && n ){
		Container cont;
		for( int i = 0; i < n; ++i ){
			pair< int, int > p;
			cin >> p.first >> p.second;
			cont.append( p );
		}
		cin >> m;
		for( int i = 0; i < m; ++i ){
			pair< int, int > p;
			cin >> p.first >> p.second;
			cont.append( p );
		}

		int result = 0;
		cont.cSort();
		result = cont.countContainment();
		cont.cSwap();
		cont.cSort();
		cout << max( result, cont.countContainment() ) << endl;
	}
	return 0;
}

Measured memory_bytes: 2008
#include<iostream>
#include<algorithm>
using namespace std;
string s;
int A,B,ALL,n,ans;
int main(){
	cin>>n;
	for(register int i=1;i<=n;i++){
		cin>>s;
		for(register int i=0;i<s.length()-1;i++)if(s[i]=='A'&&s[i+1]=='B')ans++;
		if(s[0]=='B'&&s[s.length()-1]=='A')ALL++;
		else if(s[0]=='B')B++;
		else if(s[s.length()-1]=='A')A++;
	}
	if(ALL){
		ans+=--ALL;
		if(A){
			ans++;
			--A;
		}
		if(B){
			ans++;
			--B;
		}
	}
	printf("%d",ans+min(A,B));
}

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

using namespace std;

int main(){
    int N;
    string A, B, C;
    cin >> N;
    cin >> A >> B >> C;
    int ans = 0;
    
    for(int i = 0; i < N; i++){
        if(A[i] != B[i] || A[i] != C[i]){
            if(A[i] == B[i] || B[i] == C[i] || C[i] == A[i])ans += 1;
            else ans += 2;
        }
    }
   
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)

typedef long long ll;

ll a[200000];
ll sum[200000], n, s;

// ?????????????????????x??\?????§3????????????????????¨?????§?????????
bool solve(ll x) {
	REP(i, n) {
		bool flag = true;
		int pos = i;
		REP(j, 2) {
			pos = lower_bound(sum + i, sum + i + n, sum[pos] + x) - sum;
			if (pos == i + n) { flag = false; break; }
		}
		if (flag) {
			if (i == 0 && s - sum[pos] >= x) return true;
			else if (s - (sum[pos] - sum[i]) >= x) return true;;
		}
		
	}
	
	return false;
}

int main() {
	cin >> n;
	
	REP(i, n) {
		scanf("%lld", &a[i]);
		a[n + i] = a[i];
		s += a[i];
	}
	sum[0] = a[0];
	FOR(i, 1, 2*n) sum[i] = sum[i - 1] + a[i];
	
	ll l = -1, r = n * 1000000000;
	while (r - l > 1) {
		ll m = (l + r) / 2;
		if (solve(m)) l = m;
		else r = m;
	}
	
	cout << l << endl;
	
	return 0;
}

Measured memory_bytes: 6336
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        n:usize,
        hs:[i64;n]
    }

    let mut ans = 0;
    let mut l = 0;
    while l < n {
        let mut r = l + 1;
        let mut cur = 0;
        while r < n {
            if hs[r - 1] >= hs[r] {
                cur += 1;
                r += 1;
            } else {
                break;
            }
        }
        chmax(&mut ans, cur);
        l = r;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<cstdio>
using namespace std;
int m2[150][150],stp[8][2]={{1,1},{0,1},{-1,1},{1,0},{-1,0},{1,-1},{0,-1},{-1,-1}};
bool m1[150][150];
int main()
{
	//freopen("mine.in","r",stdin);
	//freopen("mine.out","w",stdout);
	int n,m;
	char k;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=m;j++)
	  {
	  	  scanf(" %c",&k);
	  	  m1[i][j]=(k=='#');
	  }
	for(int i=1;i<=n;i++)
	  for(int j=1;j<=m;j++)
	  {
	  	  if(m1[i][j]){m2[i][j]=-1;continue;}
	  	  for(int k=0;k<8;k++)
	  	    if(m1[i+stp[k][0]][j+stp[k][1]])m2[i][j]++;
	  }
	for(int i=1;i<=n;i++)
	{
	  	for(int j=1;j<=m;j++)
		{
	  		if(m2[i][j]==-1)printf("#");
	  		else printf("%d",m2[i][j]);
		}
		printf("\n");
	}
	//fclose(stdin);
	//fclose(stdout);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fitr(it,it1,itr2) for(auto it=itr1;it!=itr2;++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int,int>> vvin;
typedef vector<pair<ll,ll>> vpll;
typedef vector<pair<int,int>> vpin;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef queue<int> qin;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
const int maxn=3e3+1;
int dp[maxn][maxn];
int choice[maxn][maxn];
int main()
{
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
string s, t;
cin>>s>>t;
vch ans;
F (i,1,(int)s.length()+1,1) {
  F (j,1,(int)t.length()+1,1) {
    // dp[i][j]= lcs of string  ending at index i and j !
    // Not picking current element 
    if (dp[i][j-1] > dp[i-1][j]) {
      dp[i][j]= dp[i][j-1];
      choice[i][j]=1;
    }
    else {
      dp[i][j]=dp[i-1][j]; 
    }
    if (s[i-1]==t[j-1]) {
      if (dp[i-1][j-1]+1 > dp[i][j]) {
        dp[i][j]=dp[i-1][j-1]+1;
        choice[i][j]=2;
      }
    }

    }
}
int i=(int)s.length() , j= (int)t.length();
while (i>=1 && j>=1) {
    if (choice [i][j]==2) { ans.pb(s[i-1]); --i; --j;} 
    else if (choice[i][j]==1)  {--j;}
    else --i;
}
reverse (fall(ans));
feach (it,ans) cout<<*it;
return 0;
}



Measured memory_bytes: 73684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vp;
typedef vector<vp> vpp;
typedef vector<vector<ll> > graph;
#define pb push_back
#define mp make_pair
#define maxi INT_MAX
#define mini INT_MIN
#define endl '\n'
void set_val(vector<ll>& v, ll val){for(ll i=0;i<v.size();i++) v[i]=val;}

ll mod = pow(10,9) + 7;
ll modulo = 998244353;
ll i_mov[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
ll j_mov[8] = {1, 1, 1, 0, -1, -1, -1, 0};

vector<vector<int>> g;
vector<int> parent, depth, subsize;

ll power(ll a, ll n)
{
    if(n==0)
    return 1;
    ll temp = power(a,n/2);
    if(n%2==0)
    return (temp*temp)%mod;
    return (((temp*temp)%mod)*a)%mod;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // cout<<fixed;
    // cout<<setprecision(18);
    ll k;
    cin>>k;
    queue<ll> q;
    for(int i=1;i<10;i++)
    q.push(i);
    ll ans = 0;
    while(k--)
    {
        ans = q.front();
        q.pop();
        if(ans%10 != 0)
        q.push(10*ans+(ans%10) -1);
        q.push(10*ans+(ans%10));
        if(ans%10 != 9)
        q.push(10*ans+(ans%10)+1);
    }
    cout<<ans<<endl;
    
} 

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int n;
bool dp[367][9][8][8][8][8];

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    vector<int> pos;
    rep(q,n){
      vector<vector<int> > a(4,vector<int>(4));
      rep(i,4)rep(j,4){
        cin>>a[i][j];
      }
      pos.push_back(0);
      rep(i,3)rep(j,3){
        if(a[i][j]+a[i][j+1]+a[i+1][j]+a[i+1][j+1]!=0){
          pos.back()|=1<<(i*3+j);
        }
      }
    }
    if((pos[0]>>4)&1){
      cout<<0<<endl;
      continue;
    }
    memset(dp,0,sizeof(dp));
    dp[1][4][1][1][1][1]=true;
    bool res=false;
    repl(i,1,n){
      rep(p,9){
        rep(a,7)rep(b,7)rep(c,7)rep(d,7){
          if(!dp[i][p][a][b][c][d])continue;
          rep(np,9){
            if(((pos[i]>>np)&1)||(p%3!=np%3&&p/3!=np/3))continue;
            if(np==0){
              dp[i+1][np][0][b+1][c+1][d+1]=true;
            }else if(np==2){
              dp[i+1][np][a+1][0][c+1][d+1]=true;
            }else if(np==6){
              dp[i+1][np][a+1][b+1][0][d+1]=true;
            }else if(np==8){
              dp[i+1][np][a+1][b+1][c+1][0]=true;
            }else{
              dp[i+1][np][a+1][b+1][c+1][d+1]=true;
            }
          }
        }
      }
    }
    rep(p,9)rep(a,7)rep(b,7)rep(c,7)rep(d,7)if(dp[n][p][a][b][c][d])res=true;
    cout<<(res?1:0)<<endl;
  }
  return 0;
}



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

int main(){
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    
    for(int i=0;i*R <= N;i++){
        for(int j=0;j*G <= N;j++){
            if((N - (i*R + j*G)) != 0 && (N - (i*R + j*G)) < B) continue;
            if((N - (i*R + j*G)) % B == 0) ans++;
        }
    }

    cout << ans << endl;
}

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

int main(){
  int M,N,ans=0;;
  int f[100][100]={0};
  string s[100];

  cin>>M>>N;
  for(int i=0;i<M;i++)
    cin>>s[i];

  for(int i=0;i<M;i++){
    for(int j=0;j<N;j++){
      if(s[i][j]=='x'){
	ans++;
	for(int c=-1;c<=1;c++){
	  for(int r=-1;r<=1;r++){
	    if(i+c>=0&&i+c<M&&j+r>=0&&j+r<N){
	      if(s[i+c][j+r]=='-'&&f[i+c][j+r]==0){
		f[i+c][j+r]=1;
		ans++;
	      }
	    }
	  }
	}
      }else if(s[i][j]=='o'){
	ans++;
	if(j-1>=0&&s[i][j-1]=='-'&&f[i][j-1]==0){
	  f[i][j-1]=1;
	  ans++;
	}
	if(j+1<N&&s[i][j+1]=='-'&&f[i][j+1]==0){
	  f[i][j+1]=1;
	  ans++;
	}
      }else if(i==0){
	if(s[i][j]='-'&&f[i][j]==0){
	  f[i][j]=1;
	  ans++;
	}
      }
    }
  }

  cout<<M*N-ans<<endl;
  
  return 0;
}

Measured memory_bytes: 3252
def resolve():
    N = int(input())
    B = list(map(int, input().split()))
    array = [0 for _ in range(N)]
    prev = B[0]
    array[0] = B[0]
    for i in range(N-1):
        if prev <= B[i]:
            array[i+1] = B[i]
        else:
            array[i] = B[i]
            array[i+1] = B[i]
        prev = B[i]
    print(sum(array))

    
if '__main__' == __name__:
    resolve()

Measured memory_bytes: 61948
#include <iostream>
#include <stdio.h>
#include <cctype>

using namespace std;

string S;
char ch;
int main(){
	while(1){
		scanf("%c", &ch);
		if(islower(ch)) ch = toupper(ch);
		else if(isupper(ch)) ch = tolower(ch);
		cout << ch;
		if(ch == '\n') break;
	}
}


Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
const ll INF = 1LL<<60;
const ll M = pow(10,9)+7;
/*template*/

int main()
{
  ll n,k;cin>>n>>k;
  ll ans=n%k;
  if(ans>k-ans)ans=k-ans;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <complex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>

#define ft first
#define sc second
#define pb push_back
#define len(v) (int)v.size()
#define int ll

using namespace std;
typedef long long ll;
typedef long double ld;


signed main() {
	#ifdef PC
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif	

	int w, h;
	cin >> w >> h;

	int cnt = (w + h - 2);
	vector<vector<int>> matrix(w, vector<int> (h, 0));
	int was = 0;
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			char c;
			cin >> c;
			if(c == '#')
				matrix[i][j] = 1, was++;
			else
				matrix[i][j] = 0;
		}
	}
	for (int i = 0; i < (1 << cnt); i++) {
		vector<int> steps;
		int ic = i;
		for(int j = 0; j < cnt; j++) {
			steps.pb(ic % 2);
			ic /= 2;
		}	
		pair<int, int> now = {0, 0};
		bool flag = 0;
		int was1 = 0;
		if(matrix[0][0]) 
			was1++;
		for (int j = 0; j < cnt; j++) {
			if(steps[j] == 1) 
				now.ft++;
			else
				now.sc++;
			if(now.ft >= w || now.sc >= h) {
				flag = 1;
				break;
			}
			if(matrix[now.ft][now.sc]) 
				was1++;
		}
		if(was1 == was && !flag) {
			cout << "Possible" << endl;
			return 0;
		}
	}
	cout << "Impossible";
	return 0;
}

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

int main(){
  long long n;
  cin >> n;
 
  string s;
  cin >> s;
  long long r=0,g=0,b=0;

  for(int i=0;i<n;i++){
    if(s.at(i) == 'R')r++;
    if(s.at(i) == 'G')g++;
    if(s.at(i) == 'B')b++;
  }

  int cnt = 0;
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      int k = j+(j-i);
      if(k>=n)break;
      if(s.at(i) != s.at(j) && s.at(j) != s.at(k) && s.at(k) != s.at(i))cnt++;
    }
  }
  cout << r*g*b - cnt << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
using namespace std;
#define INF ( 1 << 30 )
int main(){
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  cout << min(a,(min(b,c))) + min(d,e) - 50 << endl;
}

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

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

  vector<string> BubbleCard(n);

  for(int i = 0; i < n; i++) cin >> BubbleCard[i];

  vector<string> SelectCard = BubbleCard;

  for(int i = 0; i < n; i++){
    for(int j = n-1; j>=i+1; j--){
      if(BubbleCard[j][1] < BubbleCard[j-1][1]){
        string dummy;
        dummy = BubbleCard[j];
        BubbleCard[j] = BubbleCard[j-1];
        BubbleCard[j-1] = dummy;
      }
    }
  }


  for(int i = 0; i < n; i++){
    int minj = i;

    for(int j = i; j < n; j++){
      if(SelectCard[j][1] < SelectCard[minj][1]) minj = j;
    }

    if(i != minj){
      string dummy;
      dummy = SelectCard[i];
      SelectCard[i] = SelectCard[minj];
      SelectCard[minj] = dummy;
    }
  }

  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    cout << BubbleCard[i];
  }

  cout << endl;
  cout << "Stable" << endl;

  bool flag = true;

  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    cout << SelectCard[i];
    if(SelectCard[i][0] != BubbleCard[i][0]) flag = false;
  }

  cout << endl;

  if(flag) cout << "Stable" << endl;
  else cout << "Not stable" << endl;

  return 0;

}




Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int n,k; string s;
    cin>>n>>k>>s;
    if(s[k-1]=='A') s[k-1]='a';
    if(s[k-1]=='B') s[k-1]='b';
    if(s[k-1]=='C') s[k-1]='c';
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, k;
    cin >> n >> k;
    priority_queue<P> pq1;
    rep(i, n) {
        int t, d;
        cin >> t >> d;
        pq1.emplace(d, t);
    }
    ll now = 0;
    set<int> st;
    priority_queue<int, vector<int>, greater<int>> pq2;
    rep(i, k) {
        P p = pq1.top();
        pq1.pop();
        if (st.count(p.se)) {
            pq2.push(p.fi);
        } else {
            st.insert(p.se);
        }
        now += p.fi;
    }
    ll v = st.size();
    ll ans = now + v * v;
    while (!pq1.empty() && !pq2.empty()) {
        P p = pq1.top();
        pq1.pop();
        if (st.count(p.se)) continue;
        now -= pq2.top();
        pq2.pop();
        st.insert(p.se);
        now += p.fi;
        v++;
        chmax(ans, now + v * v);
    }
    cout << ans << endl;
}


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

int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c;

  x = max(a, max(b, c));
  y = x - a + x - b + x - c;
  if (y % 2 == 0) {
    cout << y / 2 << endl;
  } else {
    cout << (y + 1) / 2 + 1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0;char ch=getchar();
	while (!isdigit(ch)) ch=getchar();
	while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x;
}
int n,mx=-1,mn=0x3f3f3f3f;
int main(){
	n=read();
	for (int i=1;i<=n;++i){
		int x=read();
		mx=max(mx,x);
		mn=min(mn,x);
	}
	printf ("%d\n",mx-mn);
	return 0;
}


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

long long N,K;

   cin>>N>>K;

if(N%K==0)
cout<<"0";
else if(N<K)
cout<<min(N,abs(N-K));
else {

double a;
//a=(long double)N/(long double)K;
long long b=N/K +1;
long long c=N/K;
long long d=abs(b*K-N);
long long e=abs(c*K-N);

long long rs=min(d,e);
cout<<rs;

}



}



Measured memory_bytes: 256
MOD = 10 ** 9 + 7
def init(n=5*10**5):
    fact = [1] * (n + 1)
    for i in range(2, n+1):
        fact[i] = i * fact[i-1] % MOD
    inv = [1] * (n + 1)
    inv[n] = pow(fact[n], MOD-2, MOD)
    for i in range(n, 0, -1):
        inv[i-1] = i * inv[i] % MOD
    return fact, inv

def nCr(n, r):
    r = min(r, n - r)
    return fact[n] * (inv[n-r] * inv[r] % MOD) % MOD

def nPr(n, r):
    return fact[n] * inv[n-r] % MOD

N, M = map(int, input().split())
fact, inv = init()
res = 0
sgn = 1
for i in range(N+1):
    res += sgn * nPr(M - i, N - i) * nCr(N, i)
    res %= MOD
    sgn *= -1
print(nPr(M, N) * res % MOD)

Measured memory_bytes: 92932
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String[] s = sc.next().split("/");

        List<Integer> list = new ArrayList<>();
        for (String i : s) {
            list.add(Integer.parseInt(i));
        }
      
        String result = "TBD";
        if (list.get(1) < 5) result = "Heisei";
        
        System.out.println(result);
    }
}


Measured memory_bytes: 35548
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}

int main(){
    ll x;cin>>x;
    if(x==7 || x==5 || x==3){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3564
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#define MP make_pair
#define fi first
#define se second 
#define pb push_back
#define rep(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
const int mod=998244353;
const int N=300010;
int cj[N],inv[N];
int ans;

int power(int x,int y){
	int ret=1;
	for(;y;y>>=1,x=1ll*x*x%mod){
		if(y&1)	ret=1ll*ret*x%mod;
	}
	return ret;
}

int C(int n,int m){return 1ll*cj[n]*inv[m]%mod*inv[n-m]%mod;}

int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n;
	ll A,B,K,x;
	int i;
	scanf("%d%lld%lld%lld",&n,&A,&B,&K);
	cj[0]=1;rep(i,1,n)	cj[i]=1ll*cj[i-1]*i%mod;
	inv[n]=power(cj[n],mod-2);inv[0]=1;
	for(i=n-1;i;i--)	inv[i]=1ll*inv[i+1]*(i+1)%mod;
	rep(i,0,n){
		if(1ll*i*A>K)	break;
		x=K-1ll*i*A;
		if(x%B!=0)	continue;
		x/=B;
		if(x>n)	continue;
		ans=(ans+1ll*C(n,i)*C(n,x))%mod;
	}
	printf("%d\n",ans);
	return 0;
}


























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

int N, L, ans = 1e9, t[201], reall = 0, dif = 1e9;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); 
    
    cin >> N >> L;
    for (int i = 0; i < N; i++) reall += L + i + 1 - 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) {
                continue;
            } else {
                t[i] += L + j + 1 - 1; // we skip apple i + 1
            }
            if (abs(reall - t[i] < dif)) {
                dif = abs(reall - t[i]);
                ans = t[i];
            }
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    int a,b;
    cin >> a;
    cin >> b;
    
    int d=a/b;
    int r=a%b;
    
    double f=double(a)/double(b);
    
    cout << d;
    cout << " ";
    cout << r; 
    cout << " ";
    cout << fixed << setprecision(5) << f;
    cout << endl;
    
}



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 998244353
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


int main() {
    li a;
    cin >> a;

    printf("%.12f\n", a * a * a / 27.0);

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int n = int.Parse(Console.ReadLine());
        int[] v = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        //偶数番目の要素
        int[] odd = v.ToList().Where((name, index) => index % 2 == 0).ToArray();
        //奇数番目の要素
        int[] even = v.ToList().Where((name, index) => index % 2 == 1).ToArray();

        //重複している数字の個数を出す
        var duplicationList_Odd = odd
                             .ToList()
                             .GroupBy(x => x)
                             .Where(g => g.Count() >= 1)
                             .Select(g => new { number = g.Key, duplicationCount = g.Count() })
                             .ToList();
        var duplicationList_Even = even
                             .ToList()
                             .GroupBy(x => x)
                             .Where(g => g.Count() >= 1)
                             .Select(g => new { number = g.Key, duplicationCount = g.Count() })
                             .ToList();

        //これらを、duplicdationCountが降順になるように並び替える
        var orderByDesList_Odd = duplicationList_Odd
                                       .OrderByDescending(g => g.duplicationCount)
                                       .ToArray();
        var orderByDesList_Even = duplicationList_Even
                                       .OrderByDescending(g => g.duplicationCount)
                                       .ToArray();

        //数字がかぶっていて、変える必要のない数字の個数
        int chofuku = 0;
        
        //奇数番目で一番よく使われている数字と、偶数番目で一番よく使われている数字が違うとき→カンタン！
        if (orderByDesList_Odd.First().number != orderByDesList_Even.First().number) {
            chofuku = orderByDesList_Odd[0].duplicationCount + orderByDesList_Even[0].duplicationCount;
            //Console.WriteLine("1");
        //奇数番目で一番よく使われている数字と、偶数番目で一番よく使われている数字が同じとき→場合分け複雑！
        } else {
            //奇数番目も偶数番目も、ともに一種類しかない
            if (orderByDesList_Even.Length == 1 && orderByDesList_Odd.Length == 1) {
                chofuku = odd.Length;
            //偶数番目のみが一種類
            } else if (orderByDesList_Even.Length == 1) {
                chofuku = orderByDesList_Odd[1].duplicationCount;
            //奇数番目のみが一種類
            } else if (orderByDesList_Odd.Length == 1) {
                chofuku = orderByDesList_Even[1].duplicationCount;
            //どちらも二種類以上ある
            } else {
                chofuku = Math.Max(orderByDesList_Even[0].duplicationCount + orderByDesList_Odd[1].duplicationCount, orderByDesList_Even[1].duplicationCount + orderByDesList_Odd[0].duplicationCount);
            }
        }

        //出力
        Console.WriteLine(n - chofuku);
    }
}

Measured memory_bytes: 38092
n,k=map(int,input().split())
x=list(map(int,input().split()))
xp=[xi for xi in x if xi>=0]
xm=[xi for xi in x if xi<0]
xm.sort(reverse=True)
ans=3*10**8
for i in range(k+1):
    # xpからi個のろうそくをつける。xmからはk-i個火をつける
    if i>len(xp) or k-i>len(xm):
        continue
    a=xp[i-1] if len(xp)>0 and i>0 else 0
    b=xm[k-i-1] if len(xm)>0 and k-i>0 else 0
    ans=min(ans,2*a-b,a-2*b)
print(ans)



Measured memory_bytes: 14780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}

class comb{
  vector<ll> f,fr;
  ll MOD_;
  public:
  //a^(p-1) = 1 (mod p)(p->Prime numbers)
  //a^(p-2) = a^(-1)
  ll calc(ll a,ll b,ll p){//a^(b) mod p   
    if(b==0)return 1;
    ll y = calc(a,b/2,p);y=(y*y)%p;
    if(b & 1) y = (y * a) % p;
    return y;
  }
  void init(ll n,ll mod){//input max_n
    MOD_ = mod;
    f.resize(n+1);
    fr.resize(n+1);
    f[0]=fr[0]=1;
    for(ll i=1;i<n+1;i++){
      f[i] = (f[i-1] * i) % mod;
    }
    fr[n] = calc(f[n],mod-2,mod);
    for(ll i=n-1;i>=0;i--){
      fr[i] = fr[i+1] * (i+1) % mod;
    }
  }
  ll nCr(ll n,ll r){
    if(n<0||r<0||n<r)return 0;
    return f[n] * fr[r] % MOD_ * fr[n-r] % MOD_;
  }
};


int main(){

  ll n,k;
  cin >> n >> k;
  ll ans = 1;
  comb co;
  co.init(2*n+6,MOD);
  FOR(i,1,min(k,n)+1){
    ( ans += (co.nCr(n,i)*co.nCr(n-1,i)) % MOD ) %= MOD; 
  }
  //nHr = n+r-1Cr
  cout << ans << endl;
}


Measured memory_bytes: 6528
/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
        Comilla  University

*/
#include<bits/stdc++.h>
#define pi 2*acos(0.0)
#define ll long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define ee endl
#define pii pair<int,int>
#define infinity 10000000000000000
#define mod 1000000007
int fx[]={0,0,+1,-1};
int fy[]={+1,-1,0,0};

using namespace std;
///check n=1;
///check corner case;
const int maX=1e5+1;
vector<ll>Graph[maX],cost[maX];
ll visit[maX];
ll x[10];
ll y[10];

int main()
{
    ll n,i,j,cc=0;
    ll w,h,x,y;
    cin>>w>>h>>x>>y;
    double ans=(w*h*1.0)/2.0;
    if(x+x==w && y+y==h)cc=1;
    cout<<ans<<spc<<cc<<endl;
return 0;
}


Measured memory_bytes: 4992
N,K=map(int,input().split())
H=list(map(int,input().split()))

dp=[10**9]*(N)
dp[0]=0
for i in range(N-1):
    for j in range(1,K+1):
        if i+j<=N-1:
            dp[i+j]=min(abs(H[i]-H[i+j])+dp[i],dp[i+j])

print(dp[N-1])

Measured memory_bytes: 52448
#include <stdio.h>

int makeCombination(int, int *, int, int); 

int main()
{

  int i, n, A[20], m, q;

  scanf("%d",&n);
  for(i = 0; i < n; i++) {
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  for(i = 0; i < q; i++) {
    scanf("%d",&m);

    if(makeCombination(n,A,m,0) == 1) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int makeCombination(int n, int *A, int m, int x) {
  int res;
  if(m == 0) {
    return 1;
  }
  if(x >= n) {
    return 0;
  }
   res = makeCombination(n,A,m,x + 1) || makeCombination(n,A,m - A[x],x + 1);
  return res;
}

Measured memory_bytes: 580
from array import array

n = int(input())
v = array('i', [int(i) for i in input().split()])
c = array('i', [int(i) for i in input().split()])

Ans = 0
for i in range(n) :
    if v[i] - c[i] > 0 :
        Ans += v[i] - c[i]
print(Ans)


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

using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair

int main()
{
	ios::sync_with_stdio(false);
  	cin.tie(0);
	int n,t;
	cin >> n >> t;	
	vector<pair<int, int>> p;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin >> x >> y;
		p.pb({y, x});
	}
	sort(p.begin(), p.end());
	int ans =1e9;
	for(int i=0;i<n;i++)
	{
		if(p[i].first <= t)
		{
			if(p[i].second < ans) ans = p[i].second;
		}
	}
	if(ans < 1e9) cout << ans << "\n";
	else cout << "TLE\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
using namespace std;

int main() {
  int n;
  cin >> n;
  set<int> S;
  for(int i = 0; i < n; i++) {
    int s;
    cin >> s;
    S.insert(s);
  }
  // vector<int> S(n);
  // for(auto& v : S) {
  //   cin >> v;
  // }
  int q;
  cin >> q;
  vector<int> T(q);
  for(auto& v : T) {
    cin >> v;
  }

  int C = 0;
  for(auto t : T) {
    for(auto s : S) {
      if(t == s) C++;
    }
  }

  printf("%d\n", C);
}



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

int main()
{
    int a[6], k;
    
    for(int i = 0; i < 5; i++) cin >> a[i];
    cin >> k;
    
    for(int i = 0; i < 5; i++){
        for(int j = i+1; j < 5; j++){
            if(abs(a[i]-a[j]) > k){
                cout << ":(" << "\n";
                return 0;
            }
        }
    }
    
    cout << "Yay!" << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("ride.in");ofstream coutt("ride.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

string l;
int n,dp[100005][2];

int f(int i,int tight){
    if(i==n)return 1;
    int &ans=dp[i][tight];
    if(ans!=-1)return ans;
    
    ans=1;
    if(tight){
        ans=3*f(i+1,1)%MOD;
    }else{
        if(l[i]=='0'){
            ans=f(i+1,0)%MOD;
        }else{
            ans=((2*f(i+1,0))%MOD+f(i+1,1))%MOD;
        }
    }
    return ans;
}

signed main(){
    FASTER;
    memset(dp,-1,sizeof dp);
    cin>>l;
    n=l.size();
    cout<<f(0,0);
}

Measured memory_bytes: 9992
//sieu nhan
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inp "test.inp"
#define out "test.out"
#define oo 100005
#define inf 1e15
#define mod 1000000007
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define y1 hungdzno1
int a,p;
void nhap(){
  cin>>a>>p;
}
void xuly(){
  a*=3;
  a+=p;
  cout<<a/2;
}
main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //freopen(inp,"r",stdin);
  //freopen(out,"w",stdout);
  nhap();
  xuly();
}


Measured memory_bytes: 256