akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;

template<typename T> 
bool chmin(T&a, T b){
  if(a > b){
    a = b;
    return true;
  }
  return false;
}
template<typename T>
bool chmax(T&a, T b){
    if(a < b){
    a = b;
    return true;
  }
  return false;
}
// 入力
int N,K;
long long h[100010];

// DP テーブル
long long dp[100010];

int main(){
  int N; cin >> N;
  int K; cin >> K;
  
  for (int i = 0; i < N; ++i) cin >> h[i];

  // 初期化 (最小化問題なので INF に初期化)
  for (int i = 0; i < 100010; ++i) dp[i] = INF;

  // 初期条件
  dp[0] = 0;
  for(int i=1; i<N; i++){
  	if(i < K){
      for(int j=0; j<=i; j++){
        chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
      }
    }
    else{
      for(int j=0; j<=K; j++){
        chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
      }
    }
  }
  
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<math.h>
#define SIZE_N 100007
#define SIZE_P 100008
using namespace std;
bool flag[SIZE_N+5];
int primes[SIZE_P+5];
vector<long long>v;
void seive()
{
    int i,j,m=0,total=0,val;
    for(i=2; i<=SIZE_N; i++)
        flag[i]=1;
    val=sqrt(SIZE_N)+1;
    for(i=2; i<val; i++)
        if(flag[i])
            for(j=i; j*i<=SIZE_N; j++)
                flag[i*j]=0;
    for(i=2; i<=SIZE_N; i++)
        if(flag[i])
            primes[total++]=i;

}
int main()
{
    seive();
    long long int n;
    while(cin>>n)
    {
        long long a,b;
        while(n--)
        {
            long long ans=0,i=0;
            cin>>a>>b;
            while(primes[i]<=a)
            {
                if(primes[i]==a)
                    break;
                  i++;
            }
            while(primes[i]<=b)
            {
                if(flag[(primes[i]+1)/2]==1)
                    ans++;
                i++;
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}



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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 20;
int belong[3][N];

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, k;
	cin >> n >> k;
	if (2 * k > n + 1){
		cout << -1 << endl;
		return 0;
	}

	FILL(belong, -1);

	if (n & 1){
		const int m = (n + 1) >> 1;
		FOR(i, 0, n >> 1){
			belong[0][i] = i;
			belong[1][i + m] = i;
			belong[2][1 + 2 * i] = i;
		}
		
		FOR(i, n >> 1, n){
			belong[0][i] = i;
			belong[1][i - (n >> 1)] = i;
			belong[2][2 * (i - (n >> 1))] = i;
		}
	}else{
		FOR(i, 0, 3) belong[i][0] = 0;
		const int m = n >> 1;
		FOR(i, 1, m){
			belong[0][i] = i;
			belong[1][m + i] = i;
			belong[2][2 * i] = i;
		}
		
		FOR(i, m, n){
			belong[0][i] = i;
			belong[1][1 + i - m] = i;
			belong[2][1 + 2 * (i - m)] = i;
		}
	}
	
	vector<vector<int>> ans(n);
	FOR(i, 0, 3) FOR(j, 0, n) ans[belong[i][j]].PB(k + i * n + j);
	FOR(i, 0, n){
		assert(ans[i][0] + ans[i][1] <= ans[i][2]);
		for(auto j: ans[i]) cout << j << ' ';
		cout << '\n';
	}
		
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 20840
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author EDGE
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            long n = in.nextLong();
            long ans = Long.MAX_VALUE;
            for (long i = 1; i <= Math.sqrt(n); i++) {
                if (n % i == 0) {
                    // If divisors are equal, print only one
                    ans = Math.min(i + n / i - 2, ans);
                }
            }

            out.println(ans);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
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;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b||a==c||b==c){
        if(a==b&&b==c)cout<<"No"<<endl;
        else {
            cout<<"Yes"<<endl;
        }
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}




Measured memory_bytes: 256
n,k = map(int, input().split())
a = list(map(int, input().split()))
ans=[-1]*(k+1)
ans[0]=False # lose

for i in range(k+1):
    iswin = False
    for num in a:
        if (i-num >=0) and (not ans[i-num]):
            iswin=True
    ans[i]=iswin

if ans[-1]:
    print("First")
else:
    print("Second")

Measured memory_bytes: 44940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {

		int intWidth = 0;
		int intHeight = 0;
		int intRectangleArea = 0;
		int intRectanglePeriphery = 0;
		int intMathFormula = 2;

		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		String strWH = br.readLine();
		String[] strList = strWH.split(" ");

		String strWidth = strList[0];
		intWidth = Integer.parseInt(strList[0]);

		String strHeight = strList[1];
		intHeight = Integer.parseInt(strList[1]);

		intRectangleArea = intWidth * intHeight;

		intRectanglePeriphery = intMathFormula * (intWidth + intHeight);

		System.out.println(intRectangleArea + " " + intRectanglePeriphery);
	}
}


Measured memory_bytes: 24332
# AtCoder Beginner Contest 175
# A - Rainy Season

S=input()

ans=0

for i in range (len(S)):
    if S[i]=="R":
        tempans=1
        for j in range (i+1,len(S)):
            if S[i]==S[j]:
                tempans+=1
            else:
                if tempans>ans:
                    ans=tempans
                break
        else:
            if tempans>ans:
                ans=tempans
print(ans)

Measured memory_bytes: 8908
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

// https://betrue12.hateblo.jp/entry/2019/02/07/002335

void add(ll & a, ll b) { a = (a+b)%mod; }

int nth_bit(ll num, int n){
    return (num >> n) & 1;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll N; cin >> N;
    ll dp[61][3] = {};
    dp[60][0] = 1;

    for(int d=59; d>=0; --d){
        for(int s=0; s<=2; ++s){
            for(int k=0; k<=2; ++k){
                int s2 = min(2, 2*s + nth_bit(N, d) - k);
                if(s2 >= 0) add(dp[d][s2], dp[d+1][s]);
            }
        }
    }

    ll ans = (dp[0][0] + dp[0][1] + dp[0][2]) % mod;
    cout << ans << endl;
    
    return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> s(1);

    if(n%2) {s[0] = 1;n --;}else s[0] = 0;
    while(n != 0){
        int cnt = 0;
        while(n%(-2)==0){
            n /= (-2);
            cnt ++;
        }
        for(int i = 0;i < cnt-1;i ++){
            s.push_back(0);
        }
        if(cnt != 0) s.push_back(1);
        n --;
    } 
    for(int i = s.size()-1;i >= 0;i --){
        cout << s[i];
    }
    cout << 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;
typedef long long ll;

ll gcd(ll a, ll b)
{
	if (b == 0) return a;
	return gcd(b,a%b);
}

int main()
{
	ll A,B;
	cin >> A >> B;
	ll G = gcd(A,B);
	ll rt = sqrt(G);
	//cout << "G:" << G << endl;
	ll ans = 1;
	bool div = false;
	ll temp = G;

	for (int i = 2; i <= rt; ++i)
	{
		//cout << "a" << temp << endl;
		div = false;
		while(temp % i == 0)
		{
			div = true;
			temp /= i;
			//cout << "b" << temp << endl;
		}

		if (div) ans++;
	}

	if (temp != 1) ans++;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b;
  cin >> a >> b;
  string num_s = to_string(a) + to_string(b);
  int num = stoi(num_s);
  bool flag = false;
  for(int i=1; i*i<=num; i++){
    if(i*i == num){
      flag = true;
      break;
    }
  }
  if(flag){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

Measured memory_bytes: 256
# 一つの種類は一つまでのナップサック
# メモ化再帰で解く

N, W = map(int, input().split())

v = []
w = []
for _ in range(N):
    a, b = map(int, input().split())
    v.append(a)
    w.append(b)

memo = [[-1] * (W + 1) for _ in range(N+1)]

# i番目の品物から重さの総和がj以下となるように選ぶ
def rec(i, j):

    if memo[i][j] >= 0:
        return memo[i][j]

    # 品物が残っていない
    if (i == N):
        res = 0
    # この品物は入らない
    elif (j < w[i]):
        res = rec(i + 1, j)
    else:
        # 入れる場合といれない場合を両方試す
        res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i])
    
    memo[i][j] = res
    return res

print(rec(0, W))



Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  long long M=0;
  cin>>N;
  vector<int>vec(N);
  vector<long long>v(0);
  for(int X=0;X<N;X++){
    cin>>vec.at(X);
  }
  sort(vec.begin(),vec.end());
  for(int X=vec.at(0);X<=vec.at(N-1);X++){
    M=0;
    for(int Y=0;Y<N;Y++){
      M+=(vec.at(Y)-X)*(vec.at(Y)-X);
    }
    v.push_back(M);
  }
  sort(v.begin(),v.end());
  cout<<v.at(0)<<endl;
}


Measured memory_bytes: 3600
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);

    if(a<b){
        printf("a < b\n");
    }
    else if(a>b){
        printf("a > b\n");
    }
    else{
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
X = list(input())

q_num = X.count("?")
a_num = 0
c_num = X.count("C")
left_q_num = 0
right_q_num = q_num
ans = 0
len_x = len(X)
q_dict = []
b_ans = 0
q_ans = 0
q_dict = {}
q_dict[q_num - 1] = (3 ** (q_num - 1)) % (10 ** 9 + 7)
q_dict[q_num - 2] = (3 ** (q_num - 2)) % (10 ** 9 + 7)
q_dict[q_num - 3] = (3 ** (q_num - 3)) % (10 ** 9 + 7)
q_dict[q_num] = (3 ** (q_num)) % (10 ** 9 + 7)

if X[0] == "?":
    right_q_num -= 1
elif X[0] == "C":
    c_num -= 1
for i, x in enumerate(X):
    if x == "B" or x == "?":
        ans += (a_num * c_num)  * (q_dict[(left_q_num + right_q_num)])
        if left_q_num + right_q_num >= 2:
            ans += (right_q_num * left_q_num  + 3*(left_q_num * c_num) + 3*(right_q_num * a_num)) * (q_dict[(left_q_num + right_q_num - 2)])
        elif left_q_num + right_q_num == 1:
            ans += ((left_q_num * c_num) + (right_q_num * a_num)) * (q_dict[(left_q_num + right_q_num - 1)])
        ans = ans % (10 ** 9 + 7)
    if  i == len_x - 1:
        break
    if x == "A":
        a_num += 1
    elif x == "?":
        left_q_num += 1
    if X[i + 1] == "C":
        c_num -= 1
    elif X[i + 1] == "?":
        right_q_num -= 1

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



Measured memory_bytes: 4212
INF = 10**18

N = int(input())
H = list(map(int, input().split()))

dp = [INF for _ in range(N)]
dp[0] = 0

for i in range(N - 1):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i + 1] - H[i]))
    if i != N - 2:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i + 2] - H[i]))

print(dp[N - 1])

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

// --------------------------------------------------------------------------------
#define FASTIO	ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define fset(arr,n,val) for(int i=0;i<n;++i) arr[i] = val
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------

void solve_main()
{
    int n;cin>>n;
    unordered_set<int>st;
    frepi(1,n,1)
    {
    	int x;cin>>x;
    	st.insert(x);
    }
    if(st.size()==n)
    	cout<<"YES\n";
    else
    	cout<<"NO\n";
}

int main()
{

	// #ifndef ONLINE_JUDGE
	//	freopen("/home/suryakant/input.txt","r",stdin);
	//	freopen("/home/suryakant/output.txt","w",stdout);
	// #endif

    int t=1;
    // cin>>t;
    while(t--)
    {
        solve_main();
    }
    
}

Measured memory_bytes: 11464
#include<stdio.h>
#include<string.h>
#include<math.h>
int sub (int h[15]){
	int a;
	for(a=0;a<11;a++){
		if(h[a]==0)return a;
	}
}



int saidai(int h[15]){
	int a=10;;
	while(1){
		if(h[a]!=0){return a;}
		a--;
	}
}
		
	
	
	
int main(){
	int a,b,c,d,e,f,g,h[15]={};
	while(scanf("%d",&a)!=EOF){
		if(a!=0){
			h[sub(h)]=a;
		}else{
			printf("%d\n",h[saidai(h)]);
			h[saidai(h)]=0;
		}
	}
			
	return 0;
}

Measured memory_bytes: 600
'''
ITP-1_5-D
 ?§???????????????°???????????°
goto ?????????C/C++?¨????????????§???????????¨?????§???????????§????????????????????¨????????¶????????????????????????????????????????£?????????????????????° goto CHECK_NUM; ??¨?????????????????????????????¨???????????°??????????????§ CHECK_NUM: ??¨????????????????????????????§?????????????????????????????????£????????°?????????????????????????????????????????¨?????§????????????
?????????goto ???????????±??????????????????????????°?????????????????§?????±??????????????????????????????????????????????????¨?????¨?\¨?????????????????????
?¬????C++?¨???????????????°????????¨?????????????????????????????°????????????????????????????????????????????????goto ????????????????????§????£?????????????????????????
void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;
  cout << endl;
}
???Input
???????????´??° nn ?????????????????????????????????
???Output
????¨?????????°???????????\????????´??° nn ????????????????????????????????????????????????
'''
# import
import sys

inputData = int(input())
 
outputData = []
cntVal = 1

while True:
    # CHECK_NUM
    checkVal = cntVal
    if checkVal % 3 == 0:
        outputData.append(str(cntVal))
    else:
        while True:
            # INCLUDE3
            if checkVal % 10 == 3:
                outputData.append(str(cntVal))
                break

            checkVal = int(checkVal / 10)

            # EndChek
            if checkVal != 0: 
                continue
            else: 
                break
    # increment
    cntVal += 1

    # EndChek
    if cntVal <= inputData:
        continue
    else:
        break

# Output 
print(" " + " ".join(outputData))

Measured memory_bytes: 8000
#include <stdio.h>
int main(void){
    int n,k,rscore,sscore,pscore,i,j,ans=0;
    scanf("%d %d %d %d %d",&n,&k,&rscore,&sscore,&pscore);
    char t[n],prev,curr;
    scanf("%s",t);
    for(j=0;j<k;j++){
        prev=0;
        for(i=j;i<n;i+=k){
            curr=t[i];
            if(curr==prev){
                prev=0;
            }else{
                if(curr=='r'){
                    ans+=pscore;
                    prev='r';
                };
                if(curr=='s'){
                    ans+=rscore;
                    prev='s';
                };
                if(curr=='p'){
                    ans+=sscore;
                    prev='p';
                };
                //printf("i=%d,j=%d,curr=%c\n",i,j,curr);
            };
        };
    };
    printf("%d",ans);
    return 0;
}


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

#define N 200

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int d[ N ][ 3 ];
  int n;
  int i, j, k;

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

  for ( i = 0; i < 3; ++i )
  for ( j = 0; j < n; ++j )
  {
    const int t = d[ j ][ i ];

    for ( k = j + 1; k < n; ++k )
    {
      if ( d[ k ][ i ] == t )
      {
        d[ j ][ i ] = 0;
        d[ k ][ i ] = 0;
      }
    }
  }

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

    for ( j = 0; j < 3; ++j )
      r += d[ i ][ j ];

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

  return ( EXIT_SUCCESS );
}

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

int main() {
    string S, T;
    int A, B;
    string U;
    cin >> S >> T >> A >> B >> U;
    if (S == U) {
        cout << A-1 << " " << B << endl;
    }
    else if (T == U) {
        cout << A << " " << B-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 *
 * @author baito
 */
public class Main {

    /**
     * @param args the command line arguments
     * @throws java.io.FileNotFoundException
     */
    static int count = 0;
    public static void main(String[] args) throws Exception {
        // TODO code application logic here

        ContestScanner sc = new ContestScanner();
        int n = sc.nextInt();
        int A[] = new int[n];
        for (int i = 0; i < n; i++) {
            A[i] = sc.nextInt();
        }
        mergeSort(A, 0, n);
        StringBuilder sb = new StringBuilder();
        sb.append(A[0]);
        for (int i = 1; i < n; i++) {
            sb.append(' ').append(A[i]);
        }
        System.out.println(sb);
        System.out.println(count);
       
    }
    //??????not include
    public static void mergeSort (int[] A , int l , int r ) {
        if(l + 1 < r){
            int mid = (l + r)/2;
            mergeSort(A, l, mid);
            mergeSort(A, mid,r);
            merge(A,l,mid,r);
            
        }
        
    }
    public static void merge (int[] A , int l , int m , int r) {
        int n1  = m - l + 1;
        int n2 =  r - m + 1;
        int L[] = new int[n1];
        int R[] = new int[n2];
        System.arraycopy(A, l, L, 0, n1-1);
        L[n1-1] = Integer.MAX_VALUE;
        System.arraycopy(A, m, R, 0, n2-1);
        R[n2-1] = Integer.MAX_VALUE;
        for (int i = l, j= 0 , k= 0; i < r; i++) {
            count++;
            if(L[j] >= R[k]){
                A[i] = R[k++];
            } else {
                A[i] = L[j++];
            }
            
            
        }
        
        
    }
    
    
    
}

//????????????????????????
class ContestScanner {
    
    private final BufferedReader reader;
    private String[] line;
    private int idx;
    
    public ContestScanner() throws FileNotFoundException {
        reader = new BufferedReader(new InputStreamReader(System.in));
    }
    
    public ContestScanner(String filename) throws FileNotFoundException {
        reader = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
    }
    //???????????? 

    public String readLine() throws Exception {
        return reader.readLine();
    }
    
    public String nextToken() throws IOException {
        if (line == null || line.length <= idx) {
            line = reader.readLine().trim().split(" ");
            idx = 0;
        }
        return line[idx++];
    }
    
    public long nextLong() throws IOException, NumberFormatException {
        return Long.parseLong(nextToken());
    }
    
    public int nextInt() throws NumberFormatException, IOException {
        return (int) nextLong();
    }
    
    public double nextDouble() throws NumberFormatException, IOException {
        return Double.parseDouble(nextToken());
    }
}

Measured memory_bytes: 156684
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    int N, K; cin>>N>>K;
    vector<int> A(N);
    REP(i, N) cin>>A[i];
    sort(ALL(A));
    cout << A.end() - lower_bound(ALL(A), K) << endl;
    return 0;
}

Measured memory_bytes: 640
/**
 *   author: bholuakku
**/

#include <bits/stdc++.h>
#define For(i,a,b) for(i=(a); i<(b); i++)
#define rep(i,n) for(i=0; i<(n); i++)
#define Nfor(i,a,b) for(i=(a)-1; i>=(b); i--)
#define dep(i,n) for(i=(n-1);i>=0; i--)
#define mp make_pair
#define pb push_back
#define Auto(a) for(auto &val : a)
#define X first
#define Y second
#define MOD 1000000007
#define MOD1 998244353
#define iterate(A, i) for(auto i = A.begin(); i!=A.end(); i++)
#define mset(A,val,n) memset(A, val, n*sizeof(int))
#define Endl cout<<"\n"
#define Test cout<<"Hello\n"

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<bool> vb;
typedef vector<vector<bool> > vvb;
typedef pair<int, int> pii;
typedef vector<vector<pair<int, int> > > vvp;

int power(ll x, ll y, ll p) { ll res = 1; x = x % p; while (y>0){ if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x)%p;} return res;}
int modInverse(ll n) {ll p = MOD;return power(n, p-2, p);}
int min(int a, int b, int c) { return min(a, min(b, c)); }
int max(int a, int b, int c) { return max(a, max(b, c)); }
inline void swap(int &a, int &b) { int t = a; a = b; b = t;}
bool cmp(int a, int b){return a>b;}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1, s2;
    int i, j;
    cin>>s1>>s2;
    s1 = " "+s1; s2 = " "+s2;
    int l1 = s1.size(), l2 = s2.size();
    int dp[l1][l2];
    rep(i, l1){
        rep(j, l2){
            if(i==0||j==0) dp[i][j] = 0;
            else{
                if(s1[i]==s2[j]) dp[i][j] = dp[i-1][j-1] + 1;
                else{
                    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
                }
            }
        }
    }
    string ans = "";
    i = l1-1;
    j = l2-1;
    while(i&&j){
        if(s1[i]==s2[j]) {
            ans.pb(s1[i]);
            i--, j--;
        }
        else if(dp[i][j]==dp[i-1][j]) i--;
        else j--;
    }
    l1 = ans.size();
    rep(i, l1) cout<<ans[l1-1-i];
    return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1e5+10;
const int p=1e9+7;
vector<int>v[maxn];
int n,k,fa[maxn],ans=1;
void dfs(int u,int f=0,int dep=1,int c=0)
{
	fa[u]=f;
	int cnt=0;
	for(int i=0;i<v[u].size();i++)
	{
		if(v[u][i]==f)continue;
		dfs(v[u][i],u,dep+1,cnt++);
	}
	int tmp=k-c;
	if(dep==2)tmp--;
	if(dep>2)tmp-=2;
//	printf("%lld %lld\n",u,tmp);
	ans=(ans*tmp)%p;
}
main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1,tmp1,tmp2;i<n;i++)
	{
		scanf("%lld%lld",&tmp1,&tmp2);
		v[tmp1].push_back(tmp2);
		v[tmp2].push_back(tmp1);
	}
	dfs(1);
	printf("%lld",ans);
}

Measured memory_bytes: 15756
//23
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int n;

int dfs(const vector<char> &v,int b,int g,int r){
  if(g==0||b==0){
    return b;
  }else{
    int rb=0;
    for(int i=0;i<=r;i++){
      vector<char> nv=v;
      int x=(n-1+i)%nv.size();
      char o=nv[x];
      nv.erase(nv.begin()+x);
      rotate(nv.begin(),nv.begin()+x,nv.end());
      rb=max(rb,dfs(nv,b-(o=='B'),g-(o=='G'),r-i));
    }
    return rb;
  }
}
 
int main(){
  int t;
  cin>>t;
  while(t--){
    cin>>n;
    char g[201];
    cin>>g;
    vector<char> v;
    for(int i=0;g[i];i++){
      v.push_back(g[i]);
    }
    cout<<dfs(v,count(v.begin(),v.end(),'B'),count(v.begin(),v.end(),'G'),1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1264
#include <stdio.h>

int house[4][3][10];

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

	for (int i=0; i<n; i++) {
		int b, f, r, v;
		scanf("%d%d%d%d", &b, &f, &r, &v);

		house[b-1][f-1][r-1] += v;
	}

	for (int i=0; i<4; i++) {
		for (int j=0; j<3; j++) {
			for (int k=0; k<10; k++) {
				printf(" %d", house[i][j][k]);
			}
			putchar('\n');
		}
		if (i<3) printf("####################\n");
	}
}

Measured memory_bytes: 1040
N = int(input())
member = [int(input()) for _ in range(5)]

m = min(member)

print(4 + (N + (m - 1)) // m)
# 6 6 6 6 6
# 10000 1 10000 10000 10000

# 3 2 4 3 5
# 5 4 3 3 2
#  1 1 1 1 2.5

# 11 7 5 3 2
#   1 1 1 1 500
# 10000000007
#  5000000003.5
#  5000000008


Measured memory_bytes: 3064
def jud_oe(x):
    if x%2 == 0:
        if (x%3 == 0) or (x%5 ==0):
            return 1
        else:
            return 0
    else:
        return 1


n = int(input())
a = list(map(int,input().split()))
b = list(map(jud_oe,a))
judge = 0 in b
# print(b)
if judge:
    print("DENIED")
else:
    print("APPROVED")

Measured memory_bytes: 38256
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e6+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vector<int> MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

map<ll,ll> dp;
ll a,b,c,d;
ll INF = 1e18;
ll f(ll n)
{
	if(dp.find(n)!=dp.end()) return dp[n];
	ll dir=INF;
	if(n<INF/d) dir = n*d;
	return dp[n]=min({f(n/2)+a+(n%2)*d,f(n/3)+b+(n%3)*d,f(n/5)+c+(n%5)*d,
				f((n+1)/2)+a+(2-n%2)*d,f((n+2)/3)+(3-n%3)*d+b,f((n+4)/5)+(5-n%5)*d+c,dir});
}

int main()
{
	test()
	{
		ll n;
		cin>>n;
		cin>>a>>b>>c>>d;
		dp[0]=0;
		dp[1]=d;
		ll ans = f(n);
		cout<<ans<<endl;
		dp.clear();
	}
}		

Measured memory_bytes: 8120
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 3e5 + 10;

void prev(int s, int ctr);

int main() {
	fast_cin();
	int n, a, b;
	cin >> n >> a >> b;
	if (a + b > n + 1 or b < ((n + a - 1) / a)) {
		cout << -1;
	} else {
		int i = 0;
		for (; i <= n; ++i) {
			int k = n - i * (a - 1) + 1 - b;
			if (0 <= k and k <= a and i * a + k <= n and (i or k == a)) {
				int r = n;
				for (int j = 0; j < i; ++j) {
					prev(r, a);
					r -= a;
				}
				prev(r, k);
				r -= k;
				for (int j = r; j >= 1; --j) {
					cout << j << ' ';
				}
				break;
			}
		}
	}
}

void prev(int s, int ctr) {
	for (int i = s - ctr + 1; i <= s; ++i) {
		cout << i << ' ';
	}
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define lli long long int
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF 9223372036854775807+1
#define sosuu 1000000007

lli Euclid(lli a,lli b)
{
 
  lli r;
 
  if(a<b){
    swap(a,b);
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  return b;
}


int main(){
lli A,B,C,D;
  cin >>A>>B>>C>>D;
  lli ans=B-(B/C+B/D-B/(C*D/Euclid(C,D)))-(A-1-((A-1)/C+(A-1)/D-(A-1)/(C*D/Euclid(C,D))));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

vi Solve(ll n) {
  if (n == 0) exit(0);
  if (n == 1) return vi(0, 0);
  vi a = Solve(n / 2);
  a.push_back(a.size());
  if (n % 2) {
    reverse(a.begin(), a.end());
    a.push_back(a.size());
    reverse(a.begin(), a.end());
  }
  return a;
}

int main()
{
  ll n;
  cin >> n;
  vi result = Solve(n + 1);

  int m = result.size();
  for (int i = 0; i < m ; ++i) result.push_back(i);
  cout << result.size() << endl;
  for (int i = 0; i < result.size(); ++i) {
    if (i) cout << " ";
    cout << result[i] + 1;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3644
#pragma comment(linker,"/stack:16777216")
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<functional>
#include<utility>
#include<algorithm>
#include<sstream>
#include<cstring>
#include<cmath>
#include<cctype>
#include<exception>
#include<climits>
#include<cfloat>
#include<iomanip>
#include<bitset>
#include<streambuf>
#include<cstdlib>
#include<ctime>
//#include"functions.h"
//#include"highprecision.h"
#define pb push_back
#define pf push_front
#define ppb pop_back
#define mp make_pair
#define np next_permutation
#define fi first
#define sc second
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> >
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pff pair<float,float>
#define pdd pair<double,double>
#define psi pair<string,int>
#define pis pair<int,string>
#define ppi pair<pii,int>
#define pdi pair<pii,pii>
#define LN 84757
#define INF 1e9
#define LLINF 1e18
#define MAXINT 0x7fffffff
#define MAXLL 0x7fffffffffffffff
#define EPS 1e-5
#define DEPS 1e-9
#define LDEPS 1e-13
#define MOD 1000000007
#define E 2.7182818284
#define PI 3.1415926535
#define rep(a,b) for(int a=0;a<b;a++)
#define rep(a,b) for(int a=0;a<b;a++)
#define forn(a,n) for(int a=1;a<=n;a++)
#define forr(a,n) for(int a=n;a>=1;a--)
#define repn(a,n,p) for(int a=0;a<n;a+=p)
#define repr(a,n) for(int a=n-1;a>=0;a--)
#define foreach(a,b) for(__typeof(b.begin())a=b.begin();a!=b.end();a++)
#define fillemp(a) memset(a,0,sizeof(a))
#define fillinf(a) memset(a,0x3f,sizeof(a))
#define frestream freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define stdf(a,b) freopen(a,"r",stdin);freopen(b,"w",stdout);
#define inputf(a) freopen(a,"r",stdin);
#define outputf(a) freopen(a,"w",stdout);
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
using namespace std;

int n;
ll a[3010];
ll dp[3010][3010];
int main(int argc,char** argv){
	cin>>n;
	rep(i,n){
		cin>>a[i];
	}
	bool flag=(n%2);
	rep(i,n){
		if(flag){
			dp[i][i]=a[i];
		}
		else{
			dp[i][i]=-a[i];
		}
	}
	for(int l=2;l<=n;l++){
		for(int i=0;i<=n-l;i++){
			int j=l+i-1;
			if((n-l)%2==1){
				dp[i][j]=min(dp[i+1][j]-a[i],dp[i][j-1]-a[j]);
			}
			else{
				dp[i][j]=max(dp[i+1][j]+a[i],dp[i][j-1]+a[j]);
			}
		}
	}
	cout<<dp[0][n-1]<<endl;
	return 0;
}

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


int main() {
  int N;
  cin >> N;
  int cnt = 0;
  for (int i = N; i > 0; i --) {
    if (i < 10 || (i / 100 < 10 && i >= 100) || (i / 10000 < 10 && i >= 10000)) {
      cnt += 1;
    }
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
a,b = map(int,input().split())
c = 2
if b == 1:
    print(0)
    sys.exit()
if a >= b:
    print(1)
    sys.exit()
R = False
x = 2*a - 1
while R == False:
    if x >= b:
        R = True
    else:
        x += a-1
        c += 1
print(c)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#define PI 3.1415926
int main(void){
   int a, b, c;
   double S, L, h;
   scanf("%d %d %d", &a, &b, &c);
   S = 0.5*a*b*sin(c*PI/180);
   L = a + b + sqrt(a*a + b*b - 2*a*b*cos(c*PI/180));
   h = (2*S)/a;
   printf("%lf\n", S);
   printf("%lf\n", L);
   printf("%lf\n", h);
   return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>

using namespace std;

int n, m;
vector <string> u;
vector <string>  d;

int main() {

	cin >> n;
	for (int i = 0; i < n; ++i) {
		string tmp;
		cin >> tmp;
		u.push_back(tmp);
	}
	cin >> m;
	for (int i = 0; i < m; ++i) {
		string tmp;
		cin >> tmp;
		d.push_back(tmp);;
	}

	int ans = 0;

	for (int s = 0; s < n; ++s) {
		//青でuの中で同じ文字があるかカウント
		int cnt = 0;
		for (int p = 0; p < n; ++p) {
			if (u[s] == u[p]) {
				cnt++;
			}
		}
		//赤で同じ文字があるときは原点
		for (int k = 0; k < m; ++k) {
			if (u[s] == d[k]) {
				cnt--;
			}
		}

		if (ans < cnt) {
			ans = cnt;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int n;
ll k;
vl a,f;

bool check(ll X){
  ll cnt = 0LL;
  rep(i,n) {
    if(a[i]*f[i] > X){
      ll na = X/f[i];
      cnt += a[i]-na;
    }
  }

  return (cnt <= k);
}

int main(){
  cin >> n >> k;
  a.resize(n),f.resize(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  sort(all(a));
  sort(all(f), greater<ll>());

  ll ok = 1e18, ng = -1;
  while (abs(ng-ok)>1){
    ll mid = (ok+ng)/2;
    if(check(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}

Measured memory_bytes: 3328
import java.io.IOException;
import java.io.InputStream;
import java.util.Comparator;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int N = sc.nextInt();
		String str = sc.next();
		char back = '?';
		long count = 0;
		for (int i = 0; i < str.length(); i++) {
			if (back != str.charAt(i)) {
				count++;
				back = str.charAt(i);
			}
		}
		System.out.println(count);
	}

}

class MyComparator implements Comparator {
	@Override
	public int compare(Object arg0, Object arg1) {
		long x = (long) arg0;
		long y = (long) arg1;

		if (x < y) {
			return 1;
		} else if (x > y) {
			return -1;
		} else {
			return 0;
		}
	}
}

class FScanner {
	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: 22484
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n;
  cin >> n;
  
  map<int, int> m;
  map<int, int> m2;
  
  for (int i = 0; i < n; i++) {
    int v;
    cin >> v;
    
    if (i % 2 == 0) {
      if (m.count(v)) {
        m.at(v)++;
      } else {
        m[v] = 1;
      }
    } else {
      if (m2.count(v)) {
        m2.at(v)++;
      } else {
        m2[v] = 1;
      }
    }
  }
  
  int first = 0;
  int firstCount = 0;
  int second = 0;
  int secondCount = 0;
  for (auto x : m) {
    if (x.second > firstCount) {
      second = first;
      secondCount = firstCount;
      first = x.first;
      firstCount = x.second;
    } else if (x.second > secondCount) {
      second = x.first;
      secondCount = x.second;
    }
  }
  
  int first2 = 0;
  int firstCount2 = 0;
  int second2 = 0;
  int secondCount2 = 0;
  for (auto x : m2) {
    if (x.second > firstCount2) {
      second2 = first2;
      secondCount2 = firstCount2;
      first2 = x.first;
      firstCount2 = x.second;
    } else if (x.second > secondCount2) {
      second2 = x.first;
      secondCount2 = x.second;
    }
  }
  
  if (first != first2) {
    cout << n - firstCount - firstCount2 << endl;
  } else {
    if (firstCount + secondCount2 > secondCount + firstCount2) {
      cout << n - firstCount - secondCount2 << endl;
    } else {
      cout << n - secondCount - firstCount2 << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 4992
import sys
from fractions import gcd
from collections import defaultdict
from collections import deque
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n, m = LI()
    g = [[] for i in range(3*(n+1))]
    for i in range(m):
        u, v = LI()
        g[u].append(v + n + 1)
        g[u + n + 1].append(v + 2*(n + 1))
        g[u + 2*(n + 1)].append(v)

    s, t = LI()

    Q = deque([s])
    searched = [0 for i in range(3*(n+1))]
    searched[s] = 1
    depth = [0 for i in range(3*(n+1))]
    while len(Q) != 0:
        v = Q.popleft()
        for i in g[v]:
            if i == t:
                depth[i] = depth[v] + 1
                print(depth[i]//3)
                return
            if searched[i] == 0:
                depth[i] = depth[v] + 1
                Q.append(i)
                searched[i] = 1
    print(-1)


if __name__ == "__main__":
    main()

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

const int INF = 100000;

const int V = 10;
int cost[V][V];
int d[V];
bool used[V];

void dijkstra(int s) {
    fill(d, d + V, INF);
    fill(used, used + V, false);
    d[s] = 0;

    while (true) {
        int v = -1;

        for (int u = 0; u < V; u++)
        {
            if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
        }
        
        if (v == -1) break;

        used[v] = true;

        for (int u = 0; u < V; u++)
        {
            d[u] = min(d[u], d[v] + cost[v][u]);
        }
    }
}

int main() {
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            cin >> cost[i][j];
        }
    }
    
    int sum = 0;
    vector<int> min_dist(10, -1);
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            int a;
            cin >> a;

            if (a == -1) continue;

            if (min_dist.at(a) == -1) {
                dijkstra(a);
                min_dist.at(a) = d[1];
            }

            sum += min_dist.at(a);
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define debt 100000
 
int main(void){

	int a = debt; 
	int i,n;            

	scanf("%d",&n);
	for(i=0;i<n;i++){
		a *= 1.05;
		if(a%1000!=0)
			a+=1000;
		a=a/1000*1000;
	}
	printf("%.0d\n",a);
	return 0;
}

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


int main() {
 int N,count = 0;
 bool FP = false,FW = false,FG = false,FY = false;
 string A;
 cin >> N;

 for(int i = 0;i < N; i++){
   cin >> A;
   if (A == "P" && FP == false){
     FP = true;
     count++;
   }
   if (A == "W" && FW == false){
     FW = true;
     count++;
   }
   if (A == "G" && FG == false){
     FG = true;
     count++;
   }
   if (A == "Y" && FY == false){
     FY = true;
     count++;
   }
 } 
 if(count == 4){
   cout << "Four" << endl;
 }
 if(count == 3){
   cout << "Three" << endl;
 }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    char b;
    cin>>b;
    if(b=='A') cout<<"T"<<endl;
    if(b=='T') cout<<"A"<<endl;
    if(b=='C') cout<<"G"<<endl;
    if(b=='G') cout<<"C"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028841971693993
#define MOD 998244353
#define sec setprecision
using namespace std;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	if (n == 0)
		return 1;
	else if (x == 1)return(1);
	else if (n % 2 == 0)
		return pow(x * x, (n / 2));
	else
		return x * pow(x, n - 1);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	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;
	}
}

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

int main() {
	ll a;
	cin >> a;
	ld b;
	cin >> b;
	ll c = a * b;
	cout << c << endl;
}


Measured memory_bytes: 3732
#!/usr/bin/env python3
n, x = map(int, input().split())
a, p = [1], [1]
for i in range(n):
    a.append(2*a[i]+3)
    p.append(2*p[i]+1)


def f(n, x):
    if x == 1:
        return 0 if n != 0 else 1
    elif x <= a[n-1]+1:
        return f(n-1, x-1)
    elif x == a[n-1]+2:
        return 1 + p[n-1]
    elif x <= 2*a[n-1]+2:
        return 1 + p[n-1] + f(n-1, x-2-a[n-1])
    else:
        return 2*p[n-1]+1

print(f(n,x))

Measured memory_bytes: 3064