akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,a[21];
map<pair<int,int>,ll> f[21][21]; 
ll solve(int l,int r,int cl,int cr){
	if(l>r) return 0;
	if(l==r) return 1ll*(cl+cr)*a[l];
	if(f[l][r].count(make_pair(cl,cr))) return f[l][r][make_pair(cl,cr)];
	ll ans=1e18;
	for(int i=l;i<=r;i++)
		ans=min(ans,1ll*(cl+cr)*a[i]+solve(l,i-1,cl,cl+cr)+solve(i+1,r,cl+cr,cr));
	return f[l][r][make_pair(cl,cr)]=ans;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	cout<<a[0]+a[n-1]+solve(1,n-2,1,1)<<'\n';
	return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n; cin>>n;
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  vector<ll> S(n+1);
  rep(i,n) S[i+1]=S[i]+A[i];
  auto dp=make_v(n+1,n+1,INF);
  function<ll(ll,ll)> dfs=[&](ll L,ll R){
    if(R-L==1) return (ll)0;
    if(dp[L][R]!=INF) return dp[L][R];
    ll res=INF;
    rep(h,L+1,R) chmin(res,dfs(L,h)+dfs(h,R)+S[R]-S[L]);
    return dp[L][R]=res;
  };
  cout<<dfs(0,n)<<"\n";
}

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

const int END = -1;
struct StNod
{
  int m_nParnt;
  int m_nLeft;
  int m_nRigt;

  StNod() :
     m_nParnt(END), m_nLeft(END), m_nRigt(END)
  { }
};

void fnInput(vector<int> &rvnPodr, vector<int> &rvnIodrSeq)
{
  int nMaxSiz;

  cin >> nMaxSiz;
  rvnPodr.resize(nMaxSiz + 1);
  rvnIodrSeq.resize(nMaxSiz + 1);

  for (int i = 1; i < nMaxSiz + 1; i++)
    cin >> rvnPodr[i];

  int nNode;
  for (int i = 1; i < nMaxSiz + 1; i++)
  {
    cin >> nNode;
    rvnIodrSeq[nNode] = i;
  }
}

void fnPostOrder(const vector<int> &cnrvnPodr, const vector<int> &cnrvnIodrSeq, int nLeft, int nRight)
{
  static int stnx = 1;
  static int stnPrt = 0;

  if (nLeft == nRight) return;

  int nNode = cnrvnPodr[stnx++];
  int nMid = cnrvnIodrSeq[nNode];

  fnPostOrder(cnrvnPodr, cnrvnIodrSeq, nLeft, nMid);
  fnPostOrder(cnrvnPodr, cnrvnIodrSeq, nMid + 1, nRight);

  if (stnPrt++) cout << " ";
  cout << nNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPodr, vnIodrSeq;
  fnInput(vnPodr, vnIodrSeq);

  fnPostOrder(vnPodr, vnIodrSeq, 1, vnPodr.size());
  cout << endl;
  return 0;
}

Measured memory_bytes: 1200
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	mod int = 1e9 + 7
)

func main() {
	A := getInt()
	B := getInt()
	C := getInt()
	
	sameCnt := 0
	
	if A == B {
		sameCnt++
	}

	if A == C {
		sameCnt++
	}

	if C == B {
		sameCnt++
	}
	
	if sameCnt == 1 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val d = readLine()!!.split(' ').map(String::toLong).sorted()
    val l = n/2 - 1
    val r = n/2
    if(d[l]==d[r]){
        println(0)
        return
    }
    println(d[r]-d[l])
}

Measured memory_bytes: 56164
#include <stdio.h>

int main() {
	long long A, B;
	scanf("%lld%lld", &A, &B);

	if ((A + B) % 2 == 1) {
		printf("IMPOSSIBLE\n");
	}
	else {
        printf("%lld\n", (A + B) / 2);
	}

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
#define all(v) v.begin(),v.end()
using namespace std;
const int mo=998244353;
const int N=305;
char s[N];
int n,k,a[N];
int f[N][N];
int s1[N][N];
int s2[N][N];
int main(){
	scanf("%s%d",s+1,&k);
	n=strlen(s+1);
	int p=1;
	For(i,1,n)
		if (s[i]=='0') p++;
		else a[p]++;
	f[0][0]=1;
	int sum=0,ss=0;
	For(i,1,p) ss+=a[i];
	For(i,1,p){
		memset(s1,0,sizeof(s1));
		memset(s2,0,sizeof(s2));
		For(j,0,ss) For(k,0,ss){
			int p=min(ss+1,j+a[i]+1);
			if (p<=ss) s2[p][k+1]=(s2[p][k+1]+f[j][k])%mo;
			s1[j][k]=(s1[j][k]+f[j][k])%mo;
			s1[p][k]=(s1[p][k]+mo-f[j][k])%mo;
		}
		sum+=a[i];
		For(j,0,ss) For(k,0,ss){
			s1[j+1][k]=(s1[j+1][k]+s1[j][k])%mo;
			s2[j+1][k+1]=(s2[j+1][k+1]+s2[j][k])%mo;
			if (j>=sum) f[j][k]=(s1[j][k]+s2[j][k])%mo;
			else f[j][k]=0;
		}
		//cout<<f[sum][0]<<' '<<f[sum][1]<<endl;
	}
	int ans=0;
	For(i,0,min(k,ss)) ans=(ans+f[ss][i])%mo;//cout<<f[ss][i]<<endl;
	cout<<ans<<endl;
}

Measured memory_bytes: 4840
import itertools
N, M = map(int, input().split())
k = []
s_list = []
for _ in range(M):
  tmp = list(map(int, input().split()))
  k.append(tmp[0])
  s_list.append(tmp[1:])
p = list(map(int, input().split()))
ans = 0
for i in range(2**N):
  flag = True
  for j in range(M):
    tmp = 0
    for l in range(k[j]):
      if (i >> s_list[j][l]-1) & 1:
        tmp += 1
    if tmp%2 != p[j]:
      flag = False
      break
  if flag:
    ans += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll ADD(ll ADD_X,ll ADD_Y)
{
    return (ADD_X+ADD_Y)%MOD;
}
ll SUB(ll SUB_X,ll SUB_Y)
{
    return ((SUB_X-SUB_Y)+MOD)%MOD;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
   string s;
   cin>>s;
   int f=0;
   for(int i=0;i<3;i++){
    if(s[i]==s[i+1])
        f=1;
   }
   if(!f)
    cout<<"Good"<<endl;
   else
    cout<<"Bad"<<endl;

    return 0;
}


Measured memory_bytes: 3628
#include <cstdio>

int main (){
    int N;
    scanf("%d",&N);
    int count=0;
    int dec=10;
    if (N<dec) count=N;
    else while(N>=dec){
        count+=dec*0.9;
        if(N<dec*100 && N>=dec*10){
            count+=N-dec*10+1;
            break;
        }
        dec*=100;
    }
    printf("%d",count);
}

Measured memory_bytes: 128
#include <stdio.h>
#define MOD 1000000007

int main(void) {
	int n,m;
	long long int ans;
	
	scanf("%d %d",&n,&m);
	
	if (n > m) {
		n ^= m ^= n ^= m;
	}
	
	if (m -n > 1) {
		ans = 0;
	} else {
		ans = 1;
		for (int i = 1;i <= n;i++) {
			ans *= i;
			ans %= MOD;
			ans *= i;
			ans %= MOD;
		}
		
		if (n == m) {
			ans *= 2;
			ans %= MOD;
		} else {
			ans *= m;
			ans %= MOD;
		}
	}
	
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<lint>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    lint n;
    cin >> n;
    auto m = n-1;

    lint res = 0;

    vec div, div_m;
    for (lint i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            div.push_back(i);
            if (n/i != i) div.push_back(n/i);
        }
    }

    for (lint i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            div_m.push_back(i);
            if (m/i != i) div_m.push_back(m/i);
        }
    }

    res += div_m.size() - 1;

    for (auto&& e : div) {
        if (e == 1) continue;
        lint t = n;
        while (t % e == 0) t /= e;
        if (t % e == 1) res++;
    }

    cout << res << endl;
    return 0;
}

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

  vector<int>a(n+2,0); 
  for(int i=1; i<=n; i++){
    cin >>a[i];
  }
	// for(int i=0;i<a.size();i++)
	// 	cout<<a[i]<<" ";
	// cout<<"\n";

  vector<int>b(n+2,0);
  b[1]=a[1];
  for(int j=2; j<=n; j++){
    b[j]=__gcd(b[j-1],a[j]);
  }
	// for(int i=0;i<b.size();i++)
	// 	cout<<b[i]<<" ";
	// cout<<"\n";

  vector<int>c(n+2,0);
  c[n]=a[n];
  for(int k=n-1; k>0; k--){
    c[k]=__gcd(c[k+1],a[k]);
  }
	// for(int i=0;i<c.size();i++)
	// 	cout<<c[i]<<" ";
	// cout<<"\n";

  int answer=0;
  for(int m=1; m<=n; m++){
		// cout<<__gcd(b[m-1],c[m+1])<<" ";
    if(__gcd(b[m-1],c[m+1])>answer){
      answer=__gcd(b[m-1],c[m+1]);
    }
  }
  cout <<answer <<endl;
}


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

typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main(){
    ll x,y,z,k;cin>>x>>y>>z>>k;
    vector<ll> a(x),b(y),c(z);
    for(ll i=0;i<x;i++){
        cin>>a[i];
    }
    for(ll i=0;i<y;i++){
        cin>>b[i];
    }
    for(ll i=0;i<z;i++){
        cin>>c[i];
    }
    sort(a.begin(),a.end(),greater<ll>());
    sort(b.begin(),b.end(),greater<ll>());
    sort(c.begin(),c.end(),greater<ll>());
    vector<ll> sum;
    for(ll i=0;i<=y-1;i++){
        for(ll j=0;j<=min(2+(k/(i+1)),z-1);j++){
            sum.push_back(b[i]+c[j]);
        }
    }
    sort(sum.begin(),sum.end(),greater<ll>());
    ll s=sum.size();
    vector<ll> ans;
    for(ll i=0;i<=x-1;i++){
        for(ll j=0;j<=min(2+(k/(i+1)),s-1);j++){
            ans.push_back(a[i]+sum[j]);
        }
    }
    sort(ans.begin(),ans.end(),greater<ll>());
    for(ll i=0;i<k;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;

const long long INF = 1LL << 60;
const ll MOD = ll(1e9)+7;


int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll vector_finder(vector<ll> vec, ll number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  if (itr == vec.end()) {
    return -1;
  }
  size_t index = std::distance( vec.begin(), itr );
  return index;
}

bool has_key_using_find(unordered_map<ll, string> &m, ll n){
    if (m.find(n) == m.end()){
        return false;
    }
    else{
        return true;
    }
}

ll enum_divisors(ll N) {
    ll count = 0;
    for (ll i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            count++;
            if (N/i != i) count++;
        }
    }
    return count;
}


vector<pair<ll, ll> > prime_factorize(ll N) {
    vector<pair<ll, ll> > res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

bool IsPrime(int num) {
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}


const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];


void combinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll comb(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}




int main() {
    ll S;
    cin >> S;


    combinit();

    ll ans = 0;
    ll num = S/3;

    if (S < 3) {
        cout << ans << endl;
        return 0;
    }

    for (ll i = 1; i <= num; i++) {
        ll p = S - 3 * i;

        ans = (ans + comb(i+p-1, p))%MOD;
    }
    

    

    cout << ans%MOD << endl;


    return 0;
}

Measured memory_bytes: 15628
N, A, B = map(int, input().split())

A_amari = A % 2
B_amari = B % 2

# print(A_amari)
# print(B_amari)

if A+B == 0:
    print(0)
    exit()
else:
    cnt = N // (A+B)
    amari = N % (A+B)

# print(cnt)
# print(amari)
if amari <= A:
    print(A*cnt+amari)
else:
    if amari <= B or amari > A:
        print(A*(cnt+1))

Measured memory_bytes: 38384
fun main(args: Array<String>) {
    val (n, k) = readIntegerList()
    val ans = readLongList().sortedDescending().drop(k).sum()
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


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

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int c = 0;
  if (s[0] != 'A' || s[n-1] == 'C'){
    cout << "WA" << endl;
    return 0;
  }
  if ('a' <= s[1] && s[1] <= 'z') ;
  else{
    cout << "WA" << endl;
    return 0;
  }
  for (int i=2;i<n;i++){
    if (s[i] == 'C'){
      c++;
      continue;
    }
    if ('a' <= s[i] && s[i] <= 'z') continue;
    else{
      cout << "WA" << endl;
      return 0;
    }
  }
  if (c == 1) cout << "AC" << endl;
  else cout << "WA" << endl;
  return 0;
}
    


Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	multiset<int> st;
	vector<int> v(n);
	fri(0,n-1){
		int x;
		cin>>x;
		v[i] = x;
	}
	sort(all(v));
	int cnt = 0;
	for(int i=0;i<n-2;i++){
		for(int j=i+1;j<n-1;j++){
			cnt += upper_bound(all(v),abs(v[i]+v[j]-1)) - v.begin() - (j + 1);
		}
	}
	cout<<cnt;
	return 0;
}
//.........

Measured memory_bytes: 256
a,b=map(int,input().split())
lst={0:0,1:300000,2:200000,3:100000}
if a>3:
    x=0
else:
    x=a
if b>3:
    y=0
else:
    y=b
if x==1 and y==1:
    ans=1000000
else :
    ans=lst[x]+lst[y]


print(ans)

Measured memory_bytes: 9192
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 20 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
int a[N][N];	
int dp[(1<<21) + 1];

signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;	cin >> n;
	dp[0] = 1;
	for(int i = 1; i <= n; i++)
		for(int j = 0; j < n; j++)
			cin >> a[i][j];
	for(int mask = 0; mask < (1<<n); mask++){
		int r = __builtin_popcount(mask);
		for(int j = 0; j < n; j++){
			if(!((mask >> j) & 1) && a[r+1][j])
				dp[mask ^ (1 << j)] = (dp[mask ^ (1 << j)] + dp[mask]) % mod;
		}
	}
	cout << dp[(1<<n) - 1];
	return 0;
}

Measured memory_bytes: 8448
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>

#define int long long
#define double long double
#define incin(n) int (n); cin >> (n)
#define uniq(v) sort((v).begin(),(v).end()); (v).erase(unique((v).begin(),(v).end()),(v).end());
#define steprap(i,n,s) for(int (i)=0;i<(s)*(n);(i)+=(s))
#define rap(i,n) steprap((i),(n),1)

using intV = std::vector<int>;

using namespace std;
namespace math
{
	double PI = 3.14159265359;
	int step(int n);
	int ncr(int n,int r);
	int npr(int n,int r);
	int gcm(int a,int b);
	int lcm(int a,int b);

	int step(int n){
		if(n<=1){
			return 1;
		}else{
			return n * step(n-1);
		}
	}
	int ncr(int n,int r){
		for(int i=1;i<r;i++){
			n *= n-i;
		}
		for(int i=1;i<r;i++){
			r *= r-1;
		}
		return n/r;
	}
	int npr(int n,int r){
		for (int i = 1; i < r; ++i)
		{
			n *= n-1;
		}
		return n;
	}
	int gcm(int a,int b){
		int p=max(a,b);
		int q=min(a,b);
		int r;
		while(true){
			if(p%q==0){
				return q;
			}
			r = p%q;
			p=q;
			q=r;
		}
	}
}

using namespace std;
// using StringMap = std::vector<std::vector<char>> map(h+2,vector<char>(w+2,'#'));
namespace tmp {
    template <typename T> bool inArry(T x,vector<T> v);
    template <typename T> void input(int n,vector<T> &v);

    template <typename T> bool inArry(T x,vector<T> v){
        int l = v.size();
        for(int i=0;i<l;i++){
            if(x==v[i]){
                return true;
            }
        }
        return false;
    }
    
    template <typename T> void input(int n,vector<T> &v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
    }
}

using namespace std;

signed main (){
	string A,B,C;
	cin >> A>>B>>C;
	cout<<'A'<<B[0]<<'C'<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

class Main {
	public static void main(String args[]) throws IOException {
		@SuppressWarnings("resource")
		Scanner cin = new Scanner(System.in);
		ArrayList<String> inLines = new ArrayList<String>();
		for (; cin.hasNext();) {
			inLines.add(cin.nextLine());
		}
		Solver solver = new Solver();
		solver.solve(inLines);
	}
}

class Solver {

	public void solve(ArrayList<String> inLines) {
		int N = Integer.parseInt(inLines.get(0));
		String[] strArr = inLines.get(1).split(" ");
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = 0; i < N; i++) {
			int An = Integer.parseInt(strArr[i]);
			if (map.containsKey(An))
				map.put(An, map.get(An) + 1);
			else
				map.put(An, 1);
		}
		int cnt = 0;
		for (int key : map.keySet()) {
			if (map.get(key) % 2 == 0) {
				cnt++;
			}
		}
		if (cnt % 2 == 0)
			System.out.println(map.size());
		else
			System.out.println(map.size() - 1);
	}
}


Measured memory_bytes: 34560
import java.util.Scanner;

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

        char nextCard = 'a';
        String winner = "";

        while (winner.isEmpty()) {
            switch (nextCard) {
                case 'a':
                    if (Sa.length() == 0) {
                        winner = "A";
                        break;
                    }
                    nextCard = Sa.charAt(0);
                    Sa = Sa.substring(1, Sa.length());
                    break;
                case 'b':
                    if (Sb.length() == 0) {
                        winner = "B";
                        break;
                    }
                    nextCard = Sb.charAt(0);
                    Sb = Sb.substring(1, Sb.length());
                    break;
                case 'c':
                    if (Sc.length() == 0) {
                        winner = "C";
                        break;
                    }

                    nextCard = Sc.charAt(0);
                    Sc = Sc.substring(1, Sc.length());
                    break;

            }
        }
        System.out.println(winner);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 998244353
#define INT_MAX1 900000000
#define MAXN 1000000
#define INF INT_MAX


void solve()
{
    int n, m;
    cin >> n >> m;
    cout << (n*(n-1) + m*(m-1))/2 << endl;
}

signed main()
{
    
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>

template <typename T> double round(const T r, const int n = 0){
    if(r>=0){
        return floor(r * pow(10, -n) + 0.5) * pow(10, n);
    }
    else{
        return ceil(r * pow(10, -n) - 0.5) * pow(10, n);
    }
}

int main(){
    double a, b, c, d, e, f;
	while(std::cin >> a){
		std::cin >> b >> c >> d >> e >> f;
		std::cout << std::fixed << std::setprecision(3)
			<< round((c * e - b * f) / (a * e - b * d), -3) << ' '
			<< round((a * f - c * d) / (a * e - b * d), -3) << std::endl;
	}
	return 0;
}

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

int64_t gcd(int64_t a, int64_t b){
    return b==0 ? a : gcd(b, a%b);
}

int main(){
    int64_t N, X, D;
    cin >> N >> X >> D;

    if(D == 0){
        cout << (X == 0 ? 1 : N+1) << endl;
        return 0;
    }

    int64_t G = gcd(abs(X), abs(D));
    if(D < 0) G *= -1;
    X /= G;
    D /= G;
    int64_t ans = 0;
    for(int64_t d=0; d<=min(N, D-1); d++){
        int64_t pl = 0, pr = 0, pa = 0;
        bool first = true;
        for(int64_t i=d; i<=N; i+=D){
            int64_t l = (i-1)*i/2, r = (2*N-i-1)*i/2;
            if(!first){
                pl -= X;
                pr -= X;
                int64_t lmax = max(pl, l), lmin = min(pl, l);
                int64_t rmax = max(pr, r), rmin = min(pr, r);
                if(lmax <= rmin){
                    ans -= pa;
                    l = lmin;
                    r = rmax;
                }
            }
            first = false;
            ans += r-l+1;
            pl = l;
            pr = r;
            pa = r-l+1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    int sum1=pow(3,n);
    int sum2=1;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2==0)sum2*=2;
    }
    cout<<sum1-sum2<<endl;
}


Measured memory_bytes: 384
import sys,queue,math,copy,itertools,bisect,collections,heapq
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

s = input()
t = input()

dp = [[0 for _ in range(len(s)+1)] for _ in range(len(t)+1)]

for i in range(1,len(t)+1):
    for j in range(1,len(s)+1):
        dp[i][j] = max(dp[i][j-1],dp[i-1][j] ,dp[i-1][j-1] + (s[j-1]==t[i-1]))
i = len(t)
j = len(s)
x = dp[i][j]
ans = ''
while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        ans = ''.join([s[j-1],ans])
        i -= 1
        j -= 1
print(ans)

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

int main(void){
  int N, k, i, m=1;
  scanf("%d",&N);
  scanf("%d",&k);

  for(i=0;i<N;i++){
    if(m<k) m*=2;
    else m+=k;
  }
  printf("%d",m);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
  int k; cin >> k;
  string s; cin >> s;

  if(s.size()<=k){
    cout << s << endl;
  }
  else{
    string tmp;
    rep(i, k){
      tmp += s.at(i);
    } 
    tmp += "...";
    cout << tmp << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main(void)
{
	int n,m,d,i,j,k,cnt,sum;
	char s[101][101];
	scanf("%d %d %d",&n,&m,&d);
	for(i=0;i<n;i++)	scanf("%s",s[i]);
	sum=0;
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			cnt=1;
			if(s[i][j]=='.'){
				for(k=1;k<d;k++){
					if(s[i][j+k]=='.')	cnt++;
					else{
						cnt=1;
						break;
					}
				}
				if(cnt==d){
					sum++;
					cnt=1;
				}
				for(k=1;k<d;k++){
					if(s[i+k][j]=='.')	cnt++;
					else{
						cnt=1;
						break;
					}
				}
				if(cnt==d){
					sum++;
					cnt=1;
				}
			}
		}
	}
	printf("%d\n",sum);
	return 0;
}



Measured memory_bytes: 2092
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
#include <complex> 

using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
static const double EPS = 1e-10;

struct Edge{
  int start,end;
  int cost;
  Edge(int _s,int _e,int _c) : start(_s),end(_e),cost(_c){}
  bool operator<(const Edge& e) const{
    return cost < e.cost;
  }
};

class UnionFindTree {
private:
  int* par;
  int* rank;
  int* weight;
public:
  UnionFindTree(int n){
    par = new int[n]();
    rank = new int[n]();
    weight = new int[n]();
    for(int i=0;i<n;i++){
      par[i] = i;
      rank[i] = 0;
      weight[i] = 1;
    }
  }

  ~UnionFindTree(){
    delete[] rank;
    delete[] par;
    delete[] weight;
  }

  int find(int x){
    if(par[x] == x){
      return x;
    } else {
      return par[x] = find(par[x]);
    }
  }

  void unite(int x,int y){
    x = find(x);
    y = find(y);
    if (x == y) return;

    if(rank[x] < rank[y]){
      par[x] = y;
      weight[y] += weight[x];
    } else {
      par[y] = x;
      weight[x] += weight[y];
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  int count(int x){
    return weight[find(x)];
  }
  bool same(int x,int y){
    return find(x) == find(y);
  }
};

int main(){
  int total_nodes,total_edges;
  int nodes[100][100];
  memset(nodes,0x3f,sizeof(nodes));

  while(~scanf("%d %d",&total_nodes,&total_edges)){
    if(total_nodes == 0) break;

    vector<Edge> edges;
    for(int edge_idx = 0; edge_idx < total_edges; edge_idx++){
      int from,to,cost;
      scanf("%d %d %d",&from,&to,&cost);
      nodes[from-1][to-1] = cost;
      nodes[to-1][from-1] = cost;
      edges.push_back(Edge(from-1,to-1,cost));
    }
   
    sort(edges.begin(),edges.end());

    int opt_cost = INF;
    for(int i=0;i<total_edges;i++){
      UnionFindTree union_find(total_nodes);

      for(int j=i;j<total_edges;j++){
	union_find.unite(edges[j].start,edges[j].end);
	if(union_find.count(edges[j].start) == total_nodes){
	  opt_cost = min(opt_cost,edges[j].cost-edges[i].cost);
	  break;
	}
      }
    }
    printf("%d\n",opt_cost == INF ? -1 : opt_cost);
  }
}

Measured memory_bytes: 1368
#[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)*}
    };
}

#[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, 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")
    };
}

fn main() {
    input!{
        a: i32,
        b: i32,
    }

    println!("{}", if a * b % 2 == 0 { "No" } else { "Yes" });
}


Measured memory_bytes: 4352
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        long a = fs.nextLong();
        long b = fs.nextLong();

        long g = gcd(a,b);
        System.out.println(a*b/g);
    }

    public static long gcd(long a, long b) {
        long temp;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return b;
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


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


int main()
{
	int x, y;
	cin >> x >> y;

	if (x == 2 || y == 2)cout << "No" << endl;
	else if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) {
		if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)cout << "Yes" << endl;
		else cout << "No" << endl;
	} else {
		if (y == 4 || y == 6 || y == 9 || y == 11)cout << "Yes" << endl;
		else cout << "No" << endl;
	}

    return 0;
}



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

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

use std::cmp::max;

fn main() {
    let n: usize = read();
    let mut hint: Vec<(i64, i64, i64)> = vec![];
    let mut s = 0;

    for _ in 0..n {
        let x: i64 = read();
        let y: i64 = read();
        let h: i64 = read();
        hint.push((x, y, h));
    }

    for i in 0..hint.len() {
        let hi = hint[i];
        if hi.2 != 0 {
            s = i;
            break;
        }
    }

    for x in 0..101 {
        for y in 0..101 {
            let h = hint[s].2 + (hint[s].0 - x).abs() + (hint[s].1 - y).abs();
            let mut f = true;

            for p in &hint {
                let px = p.0;
                let py = p.1;
                let ph = p.2;
                let ti = h - (x - px).abs() - (y - py).abs();

                if max(ti, 0) != ph {
                    f = false;
                    break;
                }
            }
            if f {
                println!("{} {} {}", x, y, h);
                return;
            }
        }
    }
    //
    // for h in 0..101 {
    //     for w in 0..101 {
    //         let top = hint[s].2 + (w - hint[s].0).abs() + (h - hint[s].1).abs();
    //         if top < 0 {
    //             continue;
    //         }
    //         let mut all = true;
    //         for i in 0..hint.len() {
    //             let hi = hint[i];
    //             let ti = hi.2 + (w - hi.0).abs() + (h - hi.1).abs();
    //             if ti != top {
    //                 all = false;
    //                 break;
    //             }
    //         }
    //
    //         if all {
    //             println!("{} {} {}", w, h, top);
    //             return;
    //         }
    //     }
    // }
}


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


int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int plan1 = a*n;
  int plan2 = b;
  cout << min(plan1,plan2) << endl;
  
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(void){
  int i,n;
  int p[N],c[N];
  int priceSum=0,cSum=0;
  double cAve;
  int countAve;
  char hoge;

  for(i=0;scanf("%d%c%d",&p[i],&hoge,&c[i])==3;i++){}
  n=i;
  for(i=0;i<n;i++){
    priceSum+=p[i]*c[i];
    cSum+=c[i];
  }
  cAve=(double)cSum/n;
  cAve+=0.5;
  countAve=(int)cAve;
  printf("%d\n%d\n",priceSum,countAve);
  return 0;
}

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

int main(){
    int H,W,A,B;
    cin >> H >> W >> A >> B;

    rep(i,0,H){
        rep(j,0,W){
            if(i < B && j < A) cout << 0 ;
            else if(!(i < B) && !(j < A)) cout << 0 ;
            else if(i < B || j < A) cout << 1 ;
        }
        cout << endl;
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX
 
using namespace std;
int MOD = 998244353;
 
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
    string s;
    cin >> s;
    for(auto c: s){
        if( c == '7' ){ cout << "Yes"; return 0; }
    }
    cout << "No";
 
 
 
 
 
}

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

using namespace std;

int main()
{
  int n; cin >> n;
  string s = "";
  for(int i = 0; i < n; i++){
    string t; cin >> t;
    s += t;
  }
  for(int i = 0; ; i++){
    string x = to_string(i);
    if(s.find(x) == string::npos){ cout << i << endl; break; }
  }
  return 0;
}

Measured memory_bytes: 3268
class Condition:
  def __init__(self, s, c):
    self.pos = int(s) - 1
    self.char = c
    
  def is_match(self, number):
    return str(number)[self.pos] == self.char
  
N, M = map(int, input().split())
conditions = []
for _ in range(M):
  s, c = input().split()
  conditions.append(Condition(s, c))

for n in range(0, 1000):
  if len(str(n)) != N:
    continue
    
  if all(c.is_match(n) for c in conditions):
    print(n)
    break
else:
  print(-1)



Measured memory_bytes: 3064
def D_SmallMultiple(K):
    import collections
    q = collections.deque()
    q.append(1)  # 頂点1からスタート

    # dp[i]は1からi(0以上K未満)へ行くために必要なコスト(必要なのはdp[0])
    dp = [float('Inf') for _ in range(K)]
    dp[1] = 0

    while q:
        u = q.popleft()
        # 位置uから行ける場所を検索
        if dp[(u * 10) % K] > dp[u]:
            # コスト0(*10すること)で行ける場所
            dp[(u * 10) % K] = dp[u]
            q.appendleft((u * 10) % K)
        if dp[(u + 1) % K] > dp[u] + 1:
            # コスト1(+1すること)で行ける場所
            dp[(u + 1) % K] = dp[u] + 1
            q.append((u + 1) % K)
    return dp[0] + 1

K = int(input())
print(D_SmallMultiple(K))

Measured memory_bytes: 8388
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main() {
	int n;
	cin >> n;
	map<pair<int, int>, long long> cnt;
	for(int i = 1; i <= n; ++i) {
		string s = to_string(i);
		++cnt[{s[0] - '0', (*s.rbegin()) - '0'}];
	}
	long long answer = 0;
	for(int i = 1; i <= 9; ++i) {
		for(int j = 1; j <= 9; ++j) {
			answer += (cnt[{i, j}] * cnt[{j, i}]);
		}
	}
	cout << answer;
}


Measured memory_bytes: 3612
using System;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = 700;
            string s = Console.ReadLine();
            if (s[0] == 'o')
            {
                num += 100;
            }
            if (s[1] == 'o')
            {
                num += 100;
            }
            if (s[2] == 'o')
            {
                num += 100;
            }
            Console.WriteLine(num);
        }
    }
}

Measured memory_bytes: 13140
N = int(input())
A = [int(_) for _ in input().split()]

ans = 0
MOD = 10**9+7
for i in range(60):
    b = 1 << i
    cnt_1 = sum([a & b for a in A]) >> i
    cnt_0 = N - cnt_1
    b_sum = cnt_1 * cnt_0
    ans += (b_sum << i) % MOD
print(ans%MOD)


Measured memory_bytes: 137016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  ll N; cin >> N;
  if(N==1){
    cout << 0 << endl;
    return 0;
  }
  map<ll,int> mp;
  vector<int> A={0};
  for(int i=1;i<64;i++){
    A.pb(A.back()+i);
  }
  for(ll i = 2; i*i <= N; i++){
	  while(N%i==0) {
		  mp[i]++;
		  N /= i;
	  }
	  if(N==1) break;
  }
  if(N!=1) mp[N]++;
  ll ans = 0;
  for(auto m:mp){
    int now = m.second;
    //cout << now << endl;
    int add = 0;
    for(int i=1;i<63;i++){
      if(now>=A[i]) add = i;
      else break;
    }
    ans += add;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int main() {
	string A, B;
	cin >> A >> B;
	int rec = 0;
	if (A.length() > B.length()) {
		cout << "GREATER" << endl;
	}
	else if (A.length() < B.length()) {
		cout << "LESS" << endl;
	}
	else {
		for (int i = 0 ; i < A.length(); i++) {
			if (A[i] > B[i]) {
				cout << "GREATER" << endl;
				rec++;
				break;
			}
			else if (A[i] < B[i]) {
				cout << "LESS" << endl;
				rec++;
				break;
			}
		}
		if (rec == 0) {
			cout << "EQUAL" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3588
// 01/02/20 // 5:08 PM //

#include <bits/stdc++.h>

using namespace std;

#define int long long

const int MAXN = (int)1e2 + 10;
const int MAXK = (int)1e5 + 10;
const int MOD  = (int)1e9 + 7;

int n, k, a[MAXN];
int memo[MAXN][MAXK], prefix[MAXK];

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    cin >> n >> k;
    for(int i=1; i<=n; i++) cin >> a[i];


    for(int i=1; i<=n; i++)            memo[i][0] = 1;
    for(int j=0; j<=min(k,a[1]); j++)  memo[1][j] = 1;

    // i = 1
    prefix[0] = memo[1][0];
    for(int j=1; j<=k; j++) prefix[j] = memo[1][j] + prefix[j-1];

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

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

            if(j<=a[i])
                memo[i][j] = prefix[j]%MOD;
            else
                memo[i][j] = (prefix[j]%MOD - prefix[j-a[i]-1]%MOD + MOD)%MOD;

        }

        prefix[0] = memo[i][0]%MOD;
        for(int j=1; j<=k; j++)
            prefix[j] = (memo[i][j]%MOD + prefix[j-1]%MOD)%MOD;
    }

    cout << memo[n][k]%MOD << endl;

    return 0;
}


Measured memory_bytes: 79360
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int year = 0, month = 0, day = 0;
        for(int i=0; i<n; i++){
            int result = 0;

            year = scan.nextInt();
            month = scan.nextInt();
            day = scan.nextInt();


            for(int m = month; m<=10; m++){
                if(m==month) {
                    if (month % 2 == 1 || year % 3 == 0) {
                        result += 20 - day + 1;
                    } else {
                        result += 19 - day + 1;
                    }
                } else if(m%2==1 || year%3 == 0){
                    result += 20;
                } else{
                    result += 19;
                }
            }

            for(int y = year+1; y<1000; y++){
                for(int m = 1; m<=10; m++){
                    if(m%2==1 || y%3 == 0){
                        result += 20;
                    } else{
                        result += 19;
                    }
                }
            }
            System.out.println(result);
        }
    }
}

Measured memory_bytes: 20600
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int result = Integer.MAX_VALUE;
    for (int index = 0; index < N; index++) {
      final int a = scanner.nextInt();
      int q = a;
      int count = 0;
      while (q % 2 == 0) {
        q = q / 2;
        count++;
      }
      if (count < result) {
        result = count;
      }
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 23764
n = gets.to_i
a = gets.split.map(&:to_f)
b = a.inject(:+)/n
for i in 0..n-1
    a[i] -= b
    a[i] = [a[i].abs,i]
end
a = a.sort_by{|i,j|i}
ans = a[0]

for i in 0..n-1
    if ans[0] < a[i][0]
        break
    elsif ans[1] > a[i][1]
        ans = a[i]
    end
end
puts ans[1]

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

int main(void) {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int ans = 0;
  int cnt = 1;
  for (int i = 1; i < N; i++) {
    if (a[i] == a[i - 1])
      cnt++;
    else {
      ans += cnt / 2;
      cnt = 1;
    }
  }
  cout << ans + cnt / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] a = new double[n];
        for(int i = 0 ; i < n ; i++ ){
            a[i] = sc.nextDouble();
            a[i] = 1 / a[i];
            if(i != 0){
                a[0] += a[i];
            }
        }
        System.out.println(1 / a[0]);
    }
}

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

using namespace std;
#define int long long

signed main()
{    
    long long A,B,K;
    cin>>A>>B>>K;

    for(int i=0;i<K;i+=2){
        if(A%2==1){
            A--;
        }
        A/=2;
        B+=A;
        if(i+2<=K){
            if(B%2==1){
                B--;
            }
            B/=2;
            A+=B;
        }
    }

    cout<<A<<" "<<B<<endl;

    return 0;
}

Measured memory_bytes: 256