akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;

int main(){
    int n,m;
    cin >> n;
    string s[n];
    rep(i,n)cin >> s[i];
    cin >> m;
    string t[m];
    rep(i,m)cin >> t[i];
    int anscnt = 0;
    string ans = " ";
    rep(i,n){
        int cnt = 0;
        rep(j,n){
            if(s[i] == s[j])cnt++;
        }
        rep(j,m){
            if(s[i] == t[j])cnt--;
        }
        if(anscnt<cnt){
            ans = s[i];
            anscnt = cnt;
        }
    }
    cout << anscnt << endl;
    return 0;
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        long x = sc.nextLong();
        long k = sc.nextLong();
        long d= sc.nextLong();

        x=Math.abs(x);
        if (k<=x/d){
            pw.println(x-(k*d));
        }
        else {
            k-=x/d;
            x= x-(x/d)*d;
            long ans=x+d;
            if (k%2==0){
                ans=Math.min(ans,x);
            }else ans=Math.min(ans,Math.abs(x-d));
            pw.println(ans);
        }
        pw.close();

    }



    static class Scanner {
        BufferedReader br;
        StringTokenizer st;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

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

        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = Integer.parseInt(next());
            }
            return arr;
        }

    }

}

Measured memory_bytes: 32856
PROGRAM piyo
      IMPLICIT NONE
      INTEGER,PARAMETER :: p = 16
      integer(p) :: x,kyu,i
      
      read*,x
      
      kyu = 8
      do i = 599,1999,200
        if( x<=i )then
          print*,kyu
          stop
        else
          kyu = kyu - 1
        end if
      end do
      
      
      
      
      stop
      !debugg
      
      print*,x,i
      
      
      END PROGRAM

Measured memory_bytes: 2856
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	string a, b, c;
	cin >> n >> a >> b >> c;

	ll ans = 0;

	REP(i, n){
		if (a[i] != b[i] and b[i] != c[i] and a[i] != c[i]) ans += 2;
		else if (a[i] == b[i] and b[i] == c[i]) continue;
		else ans++;
	}

	cout << ans << endl;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;

    i64 ans = INF;
    for (i64 i = 1; i < n; i++) {
        i64 can = 0;
        for (auto e : { i, n - i }) {
            while (e) can += e % 10, e /= 10;
        }
        ans = min(ans, can);
    }

    cout << ans << endl;
}

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


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

int main(){
    int N;
    cin >> N;
    int ans = 0;
    while(N--){
        int x;
        cin >> x;
        ans += x - 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s):
    if 'LOCAL' in os.environ:
        print(s)

def main():
    global PX, nodes
    if 'BIG' in os.environ:
        N = 2* 10** 5
        Q = 2 * 10 ** 5
        AB = [[i, i + 1] for i in range(1, N)]
        PX = [[i, 10] for i in range(Q)]
    else:
        N, Q = LI()
        #  AB = []
        nodes = [[] for _ in range(N+1)]
        PX = [0] * (N+1)
        for i in range(N-1):
            a, b = LI()
            #  AB += (a, b)
            nodes[a].append(b)
            nodes[b].append(a)

        for i in range(Q):
            p, x = LI()
            PX[p] += x
        dfs(1, -1)
        print(' '.join(map(lambda x: str(x), PX[1:])))
        #  for i in PX[1:]:
        #      print(i, end=' ')
        #  ans = [0 for _ in range(N)]

def dfs(parent, parent_parent):
    for node in nodes[parent]:
        if node != parent_parent:
            PX[node] += PX[parent]
            dfs(node, parent)

if __name__ == '__main__':
    main()


Measured memory_bytes: 235932
/* AtCoder Regular Contest 078. Problem , by Abreto<m@abreto.net>. */
#include <stdio.h>
#include <stdlib.h>

int compar(const void *a, const void *b)
{
    return ((*((int*)b))-(*((int*)a)));
}

int main(void)
{
    int i = 0;
    int K = 0, N = 0;
    int l[64] = {0};
    scanf("%d%d", &N, &K);
    for(i = 0;i < N;++i)
        scanf("%d", l+i);
    qsort(l, N, sizeof(int), compar);
    N = 0;
    for(i = 0;i < K;++i)
        N += l[i];
    printf("%d\n", N);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4,sse4.1,sse4.2,tune=native")

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}



int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int a, b;
	string s;
	cin >>a >>b;
	VI z(4);
	z[a]=1; z[b]=1;
	rep2(i,1,4) if(z[i]==0){
		cout << i <<"\n";
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split(" "))
arr = list(map(int,input().split(" ")))

l=list()
l.append(0)

for i in range(1,n):
	mini= abs(arr[i] - arr[i-1]) + l[i-1]

	for j in range(2,min(k+1,i+1)):
		mini = min(mini, abs(arr[i] - arr[i-j]) + l[i-j])
	l.append(mini)

# print(l)
print(l[-1])

Measured memory_bytes: 58208
#include<bits/stdc++.h>
#define int long long
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N,M;
vector<int> S[15];
int p[15];

int ans;

bool judge(int bit){
    for(int i=0;i<M;++i){
        int cnt=0;
        for(auto u:S[i]){
            int a=1<<u;
            if(bit&a)cnt++;
        }
        if(p[i]!=cnt%2)return false;
    }
    return true;
}

signed main(){
    cin>>N>>M;
    for(int i=0;i<M;++i){
        int k;
        cin>>k;
        for(int j=0;j<k;++j){
            int s;
            cin>>s;
            s--;
            S[i].push_back(s);
        }
    }
    int all=1<<(N+1)-1;
    for(int i=0;i<M;++i)cin>>p[i];
    for(int i=0;i<all;++i)if(judge(i))ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int i=1;
    int n;
    int k;
    int ans=0;
    
    cin >> n >> k;
    
    while(1){
        
        i *= k;
        ans += 1;
        
        if(n<i){
            
            break;
            
        }
        
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
z=60,t;p(){printf("0%d:%02d:%02d\n",t/z/z,t/z%z,t%z);}main(h,m,s){for(;scanf("%d%d%d",&h,&m,&s),~h;p(t),t*=3,p(t))t=7200-h*z*z-m*z-s;exit(0);}

Measured memory_bytes: 612
n,k = map(int, input().split())
a = list(map(int, input().strip().split()))

for i in range(len(a)):
    a[i] -= 1

visited = [-1] * n
now = 0
visited[0] = 0
pre_roop = 0
pos = 0
i = 1
r = 1
while i <= k:
    next = a[now]
    #print('roop:',i,now+1,next+1)
    if visited[next] >= 0:
        r = i-visited[next]
        pre_roop = visited[next]
        pos = next
        #print(i,r,pre_roop,next)
        #print(visited)
        break
    else:
        visited[next] = i
        now = next
        #print(i,visited)
        i += 1

if i > k:
    print(now + 1)
else:
    l = (k - pre_roop) % r
    #print(l)
    i = 0
    p = pos
    while i < l:
        p = a[p]
        i +=1

    print(p+1)



Measured memory_bytes: 32408
N = int(input())
K = int(input())


def ketadp(X):
    X = '0' + str(X)
    dp = [[[0] * 4 for _ in range(2)] for _ in range(len(X))]
    dp[0][0][0] = 1
    for i in range(len(X) - 1):
        for j in range(2):
            for d in range(10 if j else int(X[i + 1]) + 1):
                if d == 0:
                    for k in range(4):
                        dp[i + 1][j or d < int(X[i + 1])][k] += dp[i][j][k]
                else:
                    for k in range(3):
                        dp[i + 1][j or d < int(X[i + 1])][k + 1] += dp[i][j][k]

    return dp[-1][0][K] + dp[-1][1][K]


print(ketadp(N))


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

const int maxn=45;
int n;
char s[maxn][maxn];
long long F[maxn][maxn][maxn][maxn],G[maxn][maxn][maxn];
bool visF[maxn][maxn][maxn][maxn],visG[maxn][maxn][maxn];
long long solveF(int l,int r,int ll,int rr);
long long solveG(int l,int r,int m);

long long solveG(int l,int r,int m){
	if(l==m&&m==r)return 1;
	if(visG[l][r][m])return G[l][r][m];
	visG[l][r][m]=true;
	for(int ll=l;ll<m;ll++)for(int rr=r;rr>m;rr--)
		G[l][r][m]+=solveG(ll+1,rr-1,m)*solveF(l,ll,rr,r);
	return G[l][r][m];
}
long long solveF(int l,int r,int ll,int rr){
	if(visF[l][r][ll][rr])return F[l][r][ll][rr];
	visF[l][r][ll][rr]=true;
	for(int m=l;m<=r;m++)for(int mm=ll;mm<=rr;mm++)
		if(s[m][mm]=='1')F[l][r][ll][rr]+=solveG(l,r,m)*solveG(ll,rr,mm);
	return F[l][r][ll][rr]; 
}

int main(){
	scanf("%d",&n);
	n*=2;
	for(int i=0;i<n;i++)scanf("%s",s[i]);
	long long ans=0;
	for(int i=1;i<n;i++)if(s[0][i]=='1')
		ans+=solveG(1,n-1,i);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 32256
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

// conversion
inline int
toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

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

//math
template <class T>
inline T sqr(T x) { return x * x; }

template <class T>
inline T nCr(T n, T r)
{
    T num = 1;
    for (int i = 1; i <= r; ++i)
    {
        num *= (n - i + 1) / i;
    }
    return num;
}
template <class T>
inline T nPr(T n, T r)
{
    r = n - r;
    T sum = 1;
    int i;
    for (i = n; i >= r + 1; --i)
        sum *= i;
    return sum;
}

template <class T>
inline T facctorial(T k)
{
    T sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

//numeric
template <class T>
inline T gcd(T a, T b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

template <class T>
inline T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())

//repetition
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
constexpr double EPS = 1e-10;
const double PI = acos(-1.0);
constexpr LL INF = 1e10;

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

int main()
{
    int m, d;
    cin >> m >> d;
    int d_1, d_10, cnt = 0;
    for (int i = 1; i <= m; ++i)
    {
        for (int j = 1; j <= d; ++j)
        {
            d_1 = j % 10;
            d_10 = j / 10;
            if (d_1 > 1 && d_10 > 1)
            {
                if ((d_1 * d_10) == i)
                {
                    ++cnt;
                }
            }
        }
    }
    cout << cnt << endl;
}

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

int A[100];

int main(void) {
	int N, B;
	cin >> N;

	for (int i = 0; i < N; i++) A[i] = 0;
	A[0] = 100000;

	for (int i = 0; i < N-1; i++) {
		cin >> B;
		A[i+1] = B;
		A[i] = min(A[i], B);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) ans += A[i];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)


# # # # class Segtree # # # #

#      0
#   1     2
# 3   4  5  6
#       :
# leaf i - n-1+i
# parent   - (i-1)//2
# children - 2*i+1, 2*i+2

class Segtree:
    # modify UNIT and oper depending on the reduce operation

    #UNIT = 0  # sum/or:0 and:fff..f min:BIG max:-BIG gcd:0 lcm:1 ..

    #@classmethod
    #def oper(c,x,y):
    #    return x|y  # sum:+ or/and/min/max/gcd/lcm:(same)

    # call like this: sgt = Segtree(n, 0, lambda x,y: max(x,y))

    def __init__(s,l,unit,oper):
        s.unit = unit
        s.oper = oper
        s.n = 1
        while s.n<l:
            s.n *= 2
        s.ary = [s.unit for i in range(2*s.n-1)]

    def get(s,i):
        return s.ary[i+s.n-1]

    def set(s,i,v):
        k = i+s.n-1
        s.ary[k] = v
        while k>0:
            k = (k-1)//2
            s.ary[k] = s.oper( \
                        s.ary[2*k+1], s.ary[2*k+2])

    def setary(s,a):
        for i,v in enumerate(a):
            s.ary[i+s.n-1] = v
        for k in range(s.n-2,-1,-1):
            s.ary[k] = s.oper( \
                        s.ary[2*k+1], s.ary[2*k+2])

    def query(s,x,y):
        l = x+s.n-1
        r = y+s.n-1
        res = s.unit
        while l<r:
            if not l%2:
                res = s.oper(res,s.ary[l])
                l += 1
            if not r%2:
                r -= 1
                res = s.oper(res,s.ary[r])
            l >>= 1
            r >>= 1
        return res


# # # # class Segtree end # # # #

from fractions import gcd
n = inn()
a = inl()
sgt = Segtree(n,0,gcd)
sgt.setary(a)
mx = max(sgt.query(1,n), sgt.query(0,n-1))
for i in range(1,n-1):
    g = gcd(sgt.query(0,i),sgt.query(i+1,n))
    mx = max(mx,g)
print(mx)


Measured memory_bytes: 100832
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] array = new Integer[m];
		int n = sc.nextInt();
		String s = sc.next();
		List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		if(list.size()%2!=0){
			System.out.println("No");
			System.exit(0);
		}
		String a = "";
		for(int i=0;list.size()/2>i;i++) {
			a=a+list.get(i);
		}
		a=a+a;
		if(a.equals(s))
			System.out.println("Yes");
		else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21716
n,a,b = map(int,input().split())
M=10**9+7

def comb(n,a):
    X = 1
    for i in range(n-a+1,n+1):
        X = X*i%M
    Y = 1
    for i in range(1,a+1):
        Y = Y*i%M
    return X*pow(Y,M-2,M)
    
ans = pow(2,n,M)-1-comb(n,a)-comb(n,b)
print(ans%M)

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

double memo[3100][3100];
double prob[3100];
int n;

double dp(int index, int jmlhH){
//	cout<<index<<" "<<jmlhH<<"\n";
	if(index == 0 ){
		return 1.0; // selesai, g bisa ubah lagi		
	}
	
	// kita pnya 2 pilihan, ubah jadi T atau ttp H
//	cout<<memo[index][jmlhH]<<" MEMO\n";
	if(memo[index][jmlhH] != -1.0) return memo[index][jmlhH];
	double ret = 0.0;
	
	ret = dp(index-1,jmlhH) * prob[index-1];
	
	if(jmlhH - 1 >= n/2){
		ret += dp(index-1,jmlhH-1) * (1.0 - prob[index-1]);
	}
	return memo[index][jmlhH] = ret;
}

int main(){
	cin>>n;
	for(int i = 0;i<n;i++){
		cin>>prob[i];
	}
	for(int i = 0;i<=n+2;i++){
		for(int j = 0;j<=n;j++){
			memo[i][j] = -1.0;
		}
	}
	
	printf("%.10f\n",dp(n+1,n));
	return 0;
}

Measured memory_bytes: 74112
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{ // floor(a/b) = (a-a%b)/b
  ll A, B, N;
  cin >> A >> B >> N;
  ll x = N;
  if(N >= B-1){
    x = B-1;
  }
  ll ans = A*(x%B)/B;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;

int main(){
    int n, x;
    cin >> n >> x;
    int nowPoint = 0;
    int nextPoint;
    int cnt = 1;
    for (int i = 0; i < n; i++)
    {
        int l;
        cin >> l;
        nextPoint = nowPoint + l;
        if (nextPoint <= x)
        {
            cnt++;
        }
        nowPoint = nextPoint;
    }
    cout << cnt << endl;
    return 0;
}

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

int
main(int argc, char** argv) {
    std::multiset<int> s;
    for (int i = 0; i < 3; i++) {
        int in;
        std::cin >> in;
        s.insert(in);
    }

    int ans = 0;
    for (auto v : s) {
        ans += v;
    }
    std::printf("%d\n", ans - *s.rbegin());
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  string x;
  
  for (int i = 0 ; i < N ; i++){
    cin >> x;
    
    if (x == "Y"){
      cout << "Four" << endl;
      break;
    }
    if (i == N-1 && x != "Y"){
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(5);

    int A, B;
    cin >> A >> B;

    int cnt = 0;
    for (int i = A; i <= B; ++i)
    {
        if ((i / 10000) == i % 10 && (i / 1000) % 10 == (i / 10) % 10)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
        public static void main(final String[] args){
            final Scanner sc = new Scanner(System.in);
            for(int i = 1; ; i++){
                int x = sc.nextInt();
                if(x == 0){
                    break;
                }else{
                    System.out.printf("Case %d: %d\n", i, x);
                }
            }
            
            sc.close();
        }
         

}


Measured memory_bytes: 66704
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if (0 < (c - a - b) && 4ll * a * b < 1ll * (c - a - b) * (c - a - b)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long a,b;
  cin >> a >> b;
  if(a % 3 == 0 || b % 3 == 0){
    cout << 0 << endl;}
    else{
      long aa = 0;
      long bb = 0;
      if(a % 3 == 1){
        long h;
        h = a / 3 * b;
        if (b % 2 == 0){
          aa = (a / 3 * 2 + 1) * b / 2 - h;}
        else{
        aa = (a / 3 * 2 + 1) * (b + 1) / 2 - h;}
      }
      else{
        long h;
        h = (a + 1) / 3 * b;
        if (b % 2 == 0){
          aa = h - (a / 3 * 2 + 1) * b / 2;}
        else{
        aa = h - (a / 3 * 2 + 1) * (b - 1) / 2;}
      }
       if(b % 3 == 1){
        long h;
        h = b / 3 * a;
        if (a % 2 == 0){
          bb = (b / 3 * 2 + 1) * a / 2 - h;}
        else{
        bb = (b / 3 * 2 + 1) * (a + 1) / 2 - h;}
      }
      else{
        long h;
        h = (b + 1) / 3 * a;
        if (a % 2 == 0){
          bb = h - (b / 3 * 2 + 1) * a / 2;}
        else{
        bb = h - (b / 3 * 2 + 1) * (a - 1) / 2;}
      }   
        cout << min(a,min(b,min(aa,bb))) << endl;
      }
  }

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

using namespace std;

struct mint {
    static const long MOD = 1000000007;
    long n;

    constexpr mint(long n = 0) : n((n % MOD + MOD) % MOD) {}
    constexpr mint operator-() const {
        return mint(-n);
    }
    constexpr mint& operator+=(const mint& rhs) {
        if ((n += rhs.n) >= MOD) n -= MOD;
        return *this;
    }
    constexpr mint& operator-=(const mint& rhs) {
        if ((n += MOD - rhs.n) >= MOD) n -= MOD;
        return *this;
    }
    constexpr mint& operator*=(const mint& rhs) {
        (n *= rhs.n) %= MOD;
        return *this;
    }
    constexpr mint operator+(const mint& rhs) const {
        mint res(*this);
        return res += rhs;
    }
    constexpr mint operator-(const mint& rhs) const {
        mint res(*this);
        return res -= rhs;
    }
    constexpr mint operator*(const mint& rhs) const {
        mint res(*this);
        return res *= rhs;
    }
    constexpr mint pow(long e) const {
        if (e == 0) return 1;
        mint a = pow(e >> 1);
        a *= a;
        if (e % 2 == 1) a *= *this;
        return a;
    }
    constexpr mint inv() const {
        return pow(MOD - 2);
    }
    constexpr mint& operator/=(const mint& rhs) {
        return *this *= rhs.inv();
    }
    constexpr mint operator/(const mint& rhs) const {
        mint res(*this);
        return res /= rhs;
    }
};

ostream& operator<<(ostream& os, const mint& a) {
    os << a.n;
    return os;
}

mint nCk(int n, int k) {
    mint nCk = 1;
    for (int i = n; i > n - k; i--) nCk *= i;
    for (int i = 1; i <= k; i++) nCk /= i;
    return nCk;
}

int main(void) {
    int n, a, b;
    cin >> n >> a >> b;

    cout << mint(2).pow(n) - 1 - nCk(n, a) - nCk(n, b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ALL(a)  (a).begin(),(a).end()
 
const ll mod = 1000000007;
const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;
 
template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}
 
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main(){
    ll a,b,k;
    cin >> a >>b >>k;

  if (k > a){
    k = k-a;
    a=0;
    
    b=b-k;
    if (b<0)b=0;
  }else{
    a= a- k;
  }
  
  cout << a << " " << b;

}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - a + b);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a;
	cin>>a;
	if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u')
	    printf("vowel\n");
	else
	    printf("consonant\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <tuple>
using ll = long long int;
ll c = 0;
ll limit;
void dfs(ll num, ll& c, bool r3, bool r5, bool r7) {
    if (num <= limit && r3 && r5 && r7) {
        c++;
    }
    else if (num > limit) {
        return;
    }
    bool r3l = r3;
    bool r5l = r5;
    bool r7l = r7;
    if (r3 == false) {
       r3l = true; 
    }
    dfs(num*10+3, c, r3l, r5, r7);
    if (r5 == false) {
       r5l = true; 
    }
    dfs(num*10+5, c, r3, r5l, r7);
    if (r7 == false) {
        r7l = true;
    }
    dfs(num*10+7, c, r3, r5, r7l);

}

int main() {
    std::cin >> limit;
    dfs(3, c, true, false, false);
    dfs(5, c, false, true, false);
    dfs(7, c, false, false, true);
    
    std::cout << c << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    	
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int K = sc.nextInt();
		int X = sc.nextInt();
		int min = X - K + 1;
		int max = X + K - 1;
		String ans = "";
	
		while(min <= max){
			if(min!=(X - K + 1)) {
				ans = ans + " ";
			}
			ans = ans + min;
			min ++;
			
		}

		System.out.println(ans);
		

   		sc.close();
        return ;

    }
    
}



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

constexpr ll INF = ll(1e+18) + 1;

ll dist(ll a, ll b, ll c, ll d) {
    return abs(a-c) + abs(b-d);
}

int main() {
    int N;
    int sum = 0, buf;
    vector<int> list;

    cin >> N;

    rep (i, N) {
        cin >> buf;
        sum += buf;
        if (buf%10 != 0) {
            list.push_back(buf);
        }
    }

    if (sum%10 != 0) {
        cout << sum << endl;
    } else {
        if (list.size() == 0) {
            cout << 0 << endl;
        } else {
            sort(list.begin(), list.end());
            cout << sum-list[0] << endl;
        }
    }

}


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

int main(){
	int nya[10];
	int hoge;
	for (int j=0;j<10;j++) {
		cin >> nya[j];
	}
	for (int i=0;i<20;i++){
		for (int k=1;k<10;k++){
			if (nya[k] > nya[k-1]) {
				hoge = nya[k-1];
				nya[k-1] = nya[k];
				nya[k] = hoge;
			}
		}
	}
//	for(int i=0;i<10;++i)	cout << nya[i] <<endl;
	cout << nya[0] << endl << nya[1] << endl << nya[2] << endl;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<int> b(n-1);
    rep(i,n-1) cin >> b[i];
    int ans = b[0]+b[n-2];
    rep2(i,1,n-1) {
        ans += min(b[i-1],b[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
def answer(n, c, k, ts):
    ts.sort()
    bus = 1
    _c = 1
    standard = ts[0]
    for i in range(1, len(ts)):
        if ts[i] <= standard+k and _c < c:
            _c += 1
        else:
            _c = 1
            standard = ts[i]
            bus += 1
    return bus
    
n, c, k = map(int, input().split())
ts = []
for _ in range(n):
    ts.append(int(input()))
print(answer(n, c, k, ts))

Measured memory_bytes: 7384
N = int(input())
A = list(map(int, input().split()))

#Ai+i = j-Aj(j > i)

dic = {}
for i in range(N):
    if dic.get(A[i]+i) == None:
        dic[A[i]+i] = 1
    else:
        dic[A[i]+i] += 1
        
ans = 0
for j in range(N):
    if dic.get(j-A[j]) != None:
        ans += dic.get(j-A[j])
print(ans)

Measured memory_bytes: 40448
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int d,e;
	int y;
	double df;
	while(scanf("%d %d",&d,&e)){
		double dfa=100000;
		if(d==0&&e==0)
		break;
		for(int x=0;x<=d;x++){
			y=d-x;
			df=sqrt((x*x)+(y*y))-e;
			if(df<0)
			df=(-1)*df;
			if(dfa>df)
			dfa=df;
		}
		printf("%lf\n",dfa);
	}
}


Measured memory_bytes: 3212
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines  

N, K, Q = map(int, input().split())

A = [K-Q for _ in range(N)]
for _ in range(Q):
  ind = int(input())
  A[ind-1] += 1

[print("Yes" if a > 0 else "No") for a in A ]


Measured memory_bytes: 8728
#include<stdio.h>

int main(void)
{
	int id, rank,a,n;
	int card[4][14];
	char c,d;

	//初期化
	for (id = 0; id < 4; id++)
	{
		for (rank = 0; rank < 14; rank++)
		{
			card[id][rank] = 0;
		}
	}
	scanf("%d", &a);
	for (int i = 0; i < a; i++)
	{
		scanf("%c", &c); //絵柄文字
		scanf("%c %d", &d, &n); //絵柄+数字
		if (d == 'S')
		{
			card[0][n] = 1;
		}
		else if (d == 'H')
		{
			card[1][n] = 1;
		}
		else if (d == 'C')
		{
			card[2][n] = 1;
		}
		else if (d == 'D')
		{
			card[3][n] = 1;
		}
	}
	for (int j = 1; j < 14; j++) //S
	{
		if (card[0][j] != 1)
		{
			printf("S %d\n", j);
		}
	}
	for (int j = 1; j < 14; j++) //H
	{
		if (card[1][j] != 1)
		{
			printf("H %d\n", j);
		}
	}
	for (int j = 1; j < 14; j++) //C
	{
		if (card[2][j] != 1)
		{
			printf("C %d\n", j);
		}
	}
	for (int j = 1; j < 14; j++) //D
	{
		if (card[3][j] != 1)
		{
			printf("D %d\n", j);
		}
	}
}


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

int n, a[200005], ri[200005], le[200005];
long long ans;
stack<int> stk1, stk2;

int main () {
    ios_base::sync_with_stdio(0); cin.tie(NULL);   
    cin >> n;
    for (int i=1; i<=n; i++) {
        cin >> a[i];
    }
    for (int i=1; i<=n; i++) {
        while (stk1.empty()==false and a[stk1.top()]>a[i]) {
            stk1.pop();
        }
        if (stk1.empty()) {
            le[i]=0;
        }
        else {
            le[i]=stk1.top();
        }
        stk1.push(i);
    }
    for (int i=n; i>=1; i--) {
        while (stk2.empty()==false and a[stk2.top()]>a[i]) {
            stk2.pop();
        }
        if (stk2.empty()) {
            ri[i]=n+1;
        }
        else {
            ri[i]=stk2.top();
        }
        stk2.push(i);
    }
    for (int i=1; i<=n; i++) {
        ans+=1LL*(i-le[i])*(ri[i]-i)*a[i];
    }
    cout << ans;
}

Measured memory_bytes: 3456
N = int(input())
A = list(map(int, input().split()))

if N == 1:
    print(1)
    exit()

def saisho_ko_baisu(A,B):
    # A < B
    if B < A:
        A,B = B,A
    x = A*B
    r = B%A
    while r!=0:
        B = A
        A = r
        r = B%A
    return x//A

A.sort()
tmp = saisho_ko_baisu(A[0], A[1])
for i in range(2,N):
    tmp = saisho_ko_baisu(tmp, A[i])
res = 0
for a in A:
    res += tmp//a

print(res % (10**9 + 7))


Measured memory_bytes: 4084
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>

using namespace std;

int main()
{
    int n,i;
    cin >> n;
    long long int sum=0,arr[3*n];
    for(i=0; i<3*n; i++)
    {
       cin >> arr[i];
    }
     sort(arr, arr+(3*n), greater<int>());
     for(i=1; i<2*n; i+=2)
    {
        sum+=arr[i];
    }
    cout << sum;
    return 0;

}


Measured memory_bytes: 5960
//#pragma warning disable
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System;
using System.Numerics;
using System.Threading.Tasks;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	long FL() => long.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	long[] GL() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(long.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Console.WriteLine(Solve());
		Out.Flush();
	}
	long Solve()
	{
		var I = G();
		int N = I[0], M = I[1];
		var uf = new UnionFindTree(N);
		for (int i = 0; i < M; i++)
		{
			I = G();
			uf.UniteCategory(I[0] - 1, I[1] - 1);
		}
		var s0 = uf.GetSize(0);
		var s1 = uf.GetSize(1);
		var ss = new List<int>();
		uf.UniteCategory(0, 1);
		for (int i = 2; i < N; i++)
			if (!uf.IsSameCategory(i, 0))
			{
				ss.Add(uf.GetSize(i));
				uf.UniteCategory(i, 0);
			}
		ss.Sort();
		var s = Max(s0, s1) + ss.Sum();
		var t = Min(s0, s1);
		return s * (s - 1L) / 2 + t * (t - 1L) / 2 - M;
	}
}
class UnionFindTree
{
	int N;
	int[] parent, rank, size;
	public UnionFindTree(int capacity)
	{
		N = capacity;
		parent = new int[N];
		rank = new int[N];
		size = new int[N];
		for (var i = 0; i < N; i++) { parent[i] = i; size[i] = 1; }
	}
	public int GetSize(int x) => size[GetRootOf(x)];
	public int GetRootOf(int x) => parent[x] == x ? x : parent[x] = GetRootOf(parent[x]);
	public bool UniteCategory(int x, int y)
	{
		if ((x = GetRootOf(x)) == (y = GetRootOf(y))) return false;
		if (rank[x] < rank[y]) { parent[x] = y; size[y] += size[x]; }
		else
		{
			parent[y] = x; size[x] += size[y];
			if (rank[x] == rank[y]) rank[x]++;
		}
		return true;
	}
	public bool IsSameCategory(int x, int y) => GetRootOf(x) == GetRootOf(y);
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    int n;cin>>n;
    VI p(n),q(n),v(n);
    REP(i,n) cin>>p[i];
    REP(i,n) cin>>q[i];

    REP(i,n) v[i] = i+1;
    int a,b;
    int c=0;
    do{
        bool fa=true;
        REP(i,n){
            if(p[i]!=v[i]){
                fa=false;
                break;
            }
        }
        if(fa){
            a = c;
        }
        bool fb=true;
        REP(i,n){
            if(q[i]!=v[i]){
                fb=false;
                break;
            }
        }
        if(fb){
            b = c;
        }

        c++;

    } while (next_permutation(v.begin(), v.end()));

    cout<<abs(a-b)<<endl;

	return;
}

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

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    char A[20],B[20],C[20];
    int i,j,k,a,b,c,d,chk1=0,chk2=0;
    scanf("%s %s %d %d %s",A,B,&a,&b,C);
    c=strlen(C);
    for(i=0; i<c; i++)
    {
        if(C[i]!=A[i])
        {
            chk1=1;
            printf("%d %d\n",a,b-1);
            break;
        }
    }
    if(chk1==0) printf("%d %d\n",a-1,b);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

using namespace std;

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

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

	for(int i = n-1; i > 0; i--) printf("%d ",A[i]);
	printf("%d\n",A[0]);
}



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

using namespace std;
#define N_MAX 200

typedef long long ll;

const ll INF = 1e+17;

void warshallfloyd(ll dist[N_MAX][N_MAX], ll edge[N_MAX][N_MAX], int n){
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            dist[i][j] = edge[i][j];
        }
        dist[i][i] = 0;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                ll new_len = dist[j][i] + dist[i][k];
                dist[j][k] = min(new_len, dist[j][k]);
            }
        }
    }
}

ll es[200][200];
ll d[200][200];
int r[8];

int main(){
    int N, M, R;
    cin >> N >> M >> R;
    for(int i = 0; i < R; i++){
        cin >> r[i];
        r[i]--;
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            es[i][j] = INF;
        }
    }
    for(int i = 0; i < M; i++){
        int A, B, C;
        cin >> A >> B >> C;
        A--; B--;
        es[A][B] = C;
        es[B][A] = C;
    }
    warshallfloyd(d, es, N);
    vector<int> v;
    ll ans = INF;
    for(int i = 0; i < R; i++) v.push_back(i);
    do {
        ll tmp = 0;
        for(int i = 1; i < R; i++){
            tmp += d[r[v[i]]][r[v[i-1]]];
        }
        ans = min(ans, tmp);
    } while (std::next_permutation(v.begin(), v.end()));
    cout << ans << endl;
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N,A,B;

int main(){
	cin >> N >> A >> B;
	if(A==1){
		if(B==N){
			repm(i,N,0) cout << i << ' ';
			cout << endl;
		} else {
			cout << -1 << endl;
		}
	} else if(B==1){
		if(A==N){
			repp(i,1,N+1) cout << i << ' ';
			cout << endl;
		} else {
			cout << -1 << endl;
		}
	} else if(A+B-1>N){
		cout << -1 << endl;
	} else if((LL)A*B<(LL)N){
		cout << -1 << endl;
	} else {
		int x = N - A;
		int m = 0;
		while(m<N){
			int y = 0;
			if(x>=B-1){
				y = B;
			} else if(x>0){
				y = x+1;
			} else {
				y = 1;
			}
			repm(i,m+y,m) cout << i << ' ';
			m += y;
			x -= y-1;
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 2176
n=int(input())
v=list(map(int,input().split()))
if n==2 and v[0]==v[1]:
    print(1)
else:
    c_e=[]
    c_o=[]
    for h in range(max(v)+1):
        c_e.append([0,h])
        c_o.append([0,h])

    for i in range(n):
        num=v[i]
        if i%2==0:
            c_e[num][0]+=1
        else:
            c_o[num][0]+=1

    c_e.sort(reverse=True)
    c_o.sort(reverse=True)
    ae=c_e[0][0]
    ao=c_o[0][0]

    if c_e[0][1]==c_o[0][1]:
        ae2=c_e[1][0]
        ao2=c_o[1][0]
        if ae2>=ao2:
            ae=ae2
        else:
            ao=ao2
            
    print(n-ae-ao)


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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for(int i = (int)a; i <= (int)b; ++i)
#define sz(s) (int)s.size()
#define all(v) v.begin(),v.end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long ll;
typedef long double ld;
const ll inf = (ll)1e18;
const ll N = (ll)1e5+77;
const ll mod = (ll)1e9+7;

int main() {
    fast;
    int n, a;
    unordered_map<int, int> mp;
    cin >> n;
    forn(i, n) cin >> a, mp[a]++;
    a = 0;
    for (auto x :  mp) {
        if (x.second >= x.first) a += x.second - x.first;
        else a += x.second;
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
bool test(string s){
	string s1="";
	for (int i=0; i<s.size(); i++){
		s1=s[i]+s1;
	}
	if (s1==s)return true;
	else return false;
}
int main(){
	string s;
	cin>>s;
	if (test(s))cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#define MN 100000
#define ll long long
using namespace std;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,rk[MN+5],num=0,ans=0;
ll s[MN+5],a[MN+5],r[MN+5];
bool cmp(int x,int y){return r[x]<r[y];}
map<ll,int> mp;
inline void Mul(ll&x,ll y){x=(1e18/x<y)?1e18:x*y;};
int main()
{
    n=read();
    for(int i=1;i<=n;++i)
    {
        a[i]=read();s[i]=r[i]=1;rk[i]=i;
        for(int j=2;j<=2160;++j) if(a[i]%j==0)
        {
            int t=0;
            while(a[i]%j==0) a[i]/=j,t=(t+1)%3;
            for(int k=0;k<t;++k) r[i]*=j;
            for(int k=0;k<(3-t)%3;++k) Mul(s[i],j);
        }
        if(a[i]>1)
        {
            int x=int(sqrt(a[i]));
            while(1LL*(x+1)*(x+1)<=a[i]) ++x;
            if(1LL*x*x==a[i]) r[i]*=a[i],Mul(s[i],x);
            else r[i]*=a[i],Mul(s[i],a[i]),Mul(s[i],a[i]);
        }
    }
    sort(rk+1,rk+n+1,cmp);int ans=n;
    for(int i=1,j;i<=n;i=j+1)
    {
        for(j=i;j<=n&&r[rk[j]]==r[rk[i]];++j);--j;
        if(r[rk[i]]==1) ans-=(j-i);
        else if(s[rk[i]]<=1e10&&mp[s[rk[i]]]) ans-=min(mp[s[rk[i]]],j-i+1);
        else mp[r[rk[i]]]=j-i+1;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 13312
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll n,x,y,res[20000];
void bfs(ll i,vector<vector<ll>> &v){
  queue<ll> q;
  q.push(i);
  vector<ll> vis(n+1,0),d(n+1,0);
  vis[i]=1;
  while(!q.empty()){
    i=q.front();
    q.pop();
    for(ll j=0;j<v[i].size();j++)
      if(!vis[v[i][j]]){
        q.push(v[i][j]);
        vis[v[i][j]]=1;
        d[v[i][j]]=d[i]+1;
      }
  }
  for(ll i=1;i<=n;i++)
    res[d[i]]++;
}
void solve(){
  cin>>n>>x>>y;
  vector<vector<ll>> v(n+1);
  for(ll i=1;i<n;i++){
    v[i].push_back(i+1);
    v[i+1].push_back(i);
  }
  v[x].push_back(y);
  v[y].push_back(x);
  for(ll i=1;i<=n;i++)
    bfs(i,v);
  for(ll i=1;i<n;i++)
    cout<<res[i]/2<<endl;
}
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll q=1;
  for(ll i=1;i<=q;i++)
    solve();
}

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

int main(int argc, char *argv[]){
  int N;
  cin>>N;
  map<char,int> mp;
  for(int i=0; i<N; i++){
    string S;
    cin>>S;
    if(i==0){
      for(int j=0; j<S.size(); j++){
	mp[S[j]]++;
      }
    }
    else{
       map<char,int> cntmp;
      for(int j=0; j<S.size(); j++){
	cntmp[S[j]]++;
      }
      for(auto itr=mp.begin(); itr!=mp.end(); itr++){
	if(cntmp.count(itr->first)){
	  if(cntmp[itr->first]<=itr->second) mp[itr->first]=cntmp[itr->first];
	}
	else mp.erase(itr);
      }
    }
  }
  for(auto itr=mp.begin(); itr!=mp.end(); itr++){
    for(int i=0; i<itr->second; i++){
      cout<<itr->first;
    }
  }
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N=4e2+20;
const long long MAX=1e14;
int n,m,l,u,v,c,q;
long long dp[N][N],dp2[N][N];
int main()
{
	scanf("%d%d%d",&n,&m,&l);

	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			dp[i][j]=MAX;
	for(int i=1;i<=n;i++) dp[i][i]=0;

	while(m--)
	{
		scanf("%d%d%d",&u,&v,&c);
		if(c>l) continue;
		dp[u][v]=dp[v][u]=c;
	}

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




	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			dp2[i][j]=MAX;
	for(int i=1;i<=n;i++) dp2[i][i]=0;

	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j and dp[i][j]<=l)
				dp2[i][j]=dp2[j][i]=1;

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

	scanf("%d",&q);
	while(q--)
	{
		scanf("%d%d",&u,&v);
		if(dp2[u][v]==MAX) printf("-1");
		else printf("%lld",dp2[u][v]-1);
		printf("\n");
	}
}

Measured memory_bytes: 2560
Q,H,S,D=map(int,input().split())
N=int(input())

C=[[0]*3 for _ in range(4)]
C[0]=[0.25,Q,4*Q]
C[1]=[0.5,H,2*H]
C[2]=[1,S,S]
C[3]=[2,D,D/2]

C.sort(key=lambda x:x[2])

if C[0][0]==2:
    if N%2!=0:
        ans=N//2*D+C[1][2]
    else:
        ans=N//2*D
else:
    ans=N*C[0][2]

print(int(ans))


Measured memory_bytes: 3064
#include <stdio.h>
int main(){
  char s[10],t[10],u[10];
  int a,b;
  scanf("%s%s%d%d%s",&s,&t,&a,&b,&u);
  if(strcmp(s,u)==0){
    printf("%d %d",a-1,b);
  }
  else{
    printf("%d %d",a,b-1);
  }
  return 0;
}
  

Measured memory_bytes: 128