akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef DEBUG
#include "_debug.cpp"
#include "callable.hpp/callable.hpp"
#endif
#define endl '\n'
using namespace std;
using ll = long long;
template <typename T, typename Function>
T bsearch(T L, T R, const Function& can, bool left_feasible = true) {
#ifdef DEBUG
    using actual_type = typename callable_traits<Function>::function_type;
    using expected_type = typename callable_traits<bool(T)>::function_type;
    static_assert(is_same<actual_type, expected_type>::value, "bsearch 'can' must be bool(T)");
#endif
    T& feasible = left_feasible ? L : R;
    T& infeasible = left_feasible ? R : L;
    while(R - L > 1) {
        T M = (L + R) / 2;
        (can(M) ? feasible : infeasible) = M;
    }
    return feasible;
}
string s;
#define N 1'000'000
int countI[N];
int countO[N];
int countJ[N];
void count(int count[N], char c) {
    for(int i = 0; i < s.length(); i++) {
        count[i] = (s[i] == c) + (i == 0 ? 0 : count[i-1]);
    }
}
bool all(int count[N], int s, int e) {
    return count[e] - (s == 0 ? 0 : count[s-1]) == (e - s + 1);
}
int longest_consec[N];
void make_longest_consec() {
    for(int i = 0; i < s.length(); i++) {
        longest_consec[i] = bsearch(1, i + 2, [&](int k) {
            if(s[i] == 'I') {
                return all(countI, i - k + 1, i);
            } else if(s[i] == 'O') {
                return all(countO, i - k + 1, i);
            } else {
                return all(countJ, i - k + 1, i);
            }
        });
    }
}
bool canI[N];
bool canO[N];
bool canJ[N];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> s;
    count(countI, 'I');
    count(countO, 'O');
    count(countJ, 'J');
    make_longest_consec();
    int ans = 0;
    for(int i = 0; i < s.length(); i++) {
        int k = longest_consec[i];
        if(s[i] == 'I'
            and i - k >= 0 and s[i - k] == 'O' and longest_consec[i - k] == k
            and i - k - k >= 0 and s[i - k - k] == 'J' and longest_consec[i - k - k] >= k) {
            ans = max(ans, k);
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 19712
#include<stdio.h>

int abs(int i,int j){
    if(i>j){
        return i-j;
    }else{
        return j-i;
    }
}

int min(int i,int j,int k){
    if(i<j){
        if(i<k){
            return i;
        }else{
            return k;
        }
    }else if(j<k){
        return j;
    }else{
        return k;
    }
}

int main(){
    int X,Y,N;
    scanf("%d %d %d",&N,&X,&Y);
    int k[N][N];
    int l[N][N];
    int a[N-1];
    int i,j,m;
    for(i=0;i<N-1;i++){
        a[i]=0;
    }
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            k[i][j]=abs(i,j);
        }
    }
    for(i=0;i<N;i++){
        for(j=0;j<N;j++){
            l[i][j]=min(k[i][X-1]+1+k[Y-1][j],k[i][Y-1]+1+k[X-1][j],k[i][j]);
        }
    }

        for(j=0;j<N;j++){
            for(m=j;m<N;m++){
                    a[l[j][m]-1]=a[l[j][m]-1]+1;
            }
        }

    for(i=0;i<N-1;i++){
        printf("%d\n",a[i]);
    }
    return 0;
}

Measured memory_bytes: 31488
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class C {
        static long MOD = 2019;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long L = in.nextLong();
            long R = in.nextLong();
            if (L == 0) {
                out.println(0);
                return;
            }

            long min = 2019;
            for (long i = L; i < Math.min(L + 9999, R); i++) {
                for (long j = i + 1; j <= Math.min(L + 9999, R); j++) {
                    min = Math.min(min, (i * j) % MOD);
                }
            }
            out.println(min);
        }

    }
}



Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(1000000)
k = int(input())
lun = []

def dfs(a, last):
    if len(a) > 0:
        lun.append(int(a))
    if len(a) > 11:
        return
    if len(a) == 0:
        for i in range(1, 10):
            a += str(i)
            dfs(a, i)
            a = a[:-1]
    else:
        if last == 0:
            candidates = [last, last + 1]
        elif last == 9:
            candidates = [last - 1, last]
        else:
            candidates = [last - 1, last, last + 1]
        for j in candidates:
            a += str(j)
            dfs(a, j)
            a = a[:-1]

dfs('', 0)
lun.sort()
print(lun[k - 1])

Measured memory_bytes: 78164
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, X;
	cin >> N >> X;
	vector<int>M(N);
	rep(i, N) {
		cin >> M[i];
	}
	sort(M);
	int sum = 0;
	rep(i, N) {
		sum += M[i];
	}
	cout << (X - sum) / M[0]+N << endl;
}

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


int main(){
    int N;
    cin >> N;
    vector<int> W(N);
    int allsum=0;
    for(int i=0; i<N; i++){
        cin >> W.at(i);
        allsum += W.at(i);
    }
    int ansmin=1e5;

    for(int i=0; i<N-1; i++){
        int sum=0;
        for(int j=0; j<i+1;j++){
            sum+=W.at(j);
        }
        sum = sum*2;
        ansmin = min(ansmin,abs(allsum-sum));
    }
    cout << ansmin;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  string S;cin>>S;
  int x=0,ans=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='I')x++;
    else x--;
    ans=max(x,ans);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
def e():
    N, W = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(N)]
    v = [wv[i][1] for i in range(len(wv))]
    V = sum(v)
    dp = [[10 ** 9] * (V + 1) for _ in range(N + 1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(V + 1):
            if j - wv[i][1] >= 0:
                dp[i + 1][j] = min(dp[i + 1][j],
                                   dp[i][j - wv[i][1]] + wv[i][0])
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
    for k, p in enumerate(dp[-1]):
        if p <= W:
            r = k
    return r


if __name__ == '__main__':
    ans = e()
    print(ans)

Measured memory_bytes: 119484
import java.util.Scanner;

public class Main {
    public static void main(String[] argv) {
        Scanner scanner = new Scanner(System.in);

        String line = scanner.nextLine();
        int l = Integer.parseInt(line);

        double side = (double)l / 3;

        double ans = side * side * side;

        System.out.println(ans);

    }
}

Measured memory_bytes: 21588
#include<bits/stdc++.h>
using namespace std;
int main (){
    long long int A, B, N;
    long long int a;
    cin >> N >> A >> B;
    if(N<=A){
        cout << N << endl;
        return 0;
    }
  if(A==0 && B==0){
    cout<<"0"<<endl;
  }

    if(A==0){
        cout << "0" << endl;
        return 0;
    }
  
  if(N%(A+B)>A){
  cout<<A*(N/(A+B)) + A<<endl;
  }else{
    cout<<A*(N/(A+B))+N%(A+B)<<endl;
  
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}
int sa(int a,int b){return (a%b==0?b:sa(b,a%b));}

signed main(void){
    int n;cin>>n;
    int a[n];rep(i,n) cin>>a[i];
    int ans=sa(a[0],a[1]);
    loop(i,2,n){
        ans=sa(ans,a[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
takahashi,aoki,K = list(map(int,input().split()))

if K <= takahashi:
	takahashi -= K
elif K <= takahashi + aoki:
	aoki -= (K-takahashi)
	takahashi = 0
else:
	takahashi = 0
	aoki = 0
print(takahashi,aoki)

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int a,b,x;

	cin >> a >> b >> x;

	if(a+b >= x && a <= x)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from bisect import bisect, insort, bisect_left
n = int(input())
s = list(input())
q = int(input())
d = defaultdict(list)
for i in range(n):
    d[s[i]] += [i]
for _ in range(q):
    t, i, c = input().split()
    t, i = int(t), int(i) - 1
    if t == 1:
        if s[i] == c:
            continue
        d[s[i]].pop(bisect(d[s[i]], i) - 1)
        s[i] = c
        insort(d[c], i)
    else:
        res = 0
        c = int(c) - 1
        for j in d.values():
            if bisect(j, c) - bisect_left(j, i):
                res += 1
        print(res)

Measured memory_bytes: 35172
import java.util.Scanner;
import static java.lang.Math.sqrt;

class Main {
    private static int[] calcPrimes(int n) {
        boolean[] table = new boolean[n + 1];
        for (int i = 2; i <= Math.sqrt(n); i++) {
            if (!table[i]) {
                for (int j = i + i; j <= n; j += i) {
                    table[j] = true;
                }
            }
        }
        int counter = 0;
        for (int i = 2; i <= n; i++) {
            if (!table[i]) {
                counter++;
            }
        }
        int[] result = new int[counter];
        int index = 0;
        for (int i = 2; i <= n; i++) {
            if (!table[i]) {
                result[index++] = i;
            }
        }
        return result;
    }

    private static void solve() {
        Scanner scanner = new Scanner(System.in);
        int[] primes = calcPrimes(1000000);

        while (scanner.hasNextLong()) {
            long l = scanner.nextLong();
            if (l == 0) {
                break;
            }

            int result = 1;
            for (int i = 0; i < primes.length && primes[i] <= sqrt(l); i++) {
                if (l % primes[i] == 0) {
                    int counter = 0;
                    while (l % primes[i] == 0) {
                        l /= primes[i];
                        counter++;
                    }
                    result *= (2 * counter) + 1;
                }
            }
            if (l != 1) {
                result *= 3;
            }
            result = result / 2 + 1;
            System.out.println(result);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

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

//#define DBG

#ifdef DBG
#include <unistd.h>
#endif
using namespace std;

using ll = long long;

const ll MOD = 998244353;

ll tbl[100000 + 1] = {0LL};
ll tblsum[100000 + 1] = {0LL};

ll N, X, M;

ll myf(ll x, ll m) {
    return (x * x) % m;
}

ll solver(){
    ll ans = 0;
    ll a = X;
    for(int i = 1; i <= N; i++){
        ans += a;
        a = myf(a, M);
        if(a == 0){
            return ans;
        }
    }
    return ans;
}

ll solver2(){
#ifdef DBG
    cout << "Ran sol2" << endl;
#endif
    // ループを見つける
    ll block = 0;
    ll a = X;

    ll loop = 0;
    ll bblock;
    for(ll i = 1; i <= N; i++){
        if(tbl[a] != 0) {
            #ifdef DBG
            cout << "Already " << a << " on " << tbl[a] << " i = " << i << endl;
            //sleep(3);
            #endif
            bblock = block - tblsum[a];
            loop = i - tbl[a];
            break;
        }
        tbl[a] = i;
        tblsum[a] = block;
        block += a;
        a = myf(a, M); // ここからaはa_{i+1}
        if(a == 0){
            return block;
        }
    }
    ll ans = tblsum[a] + bblock * ((N - (tbl[a] - 1)) / loop);

    ll ex = (N - (tbl[a] - 1)) % loop;

    for(int i = 1; i <= ex; i++){
        ans += a;
        a = myf(a, M);
        if(a == 0){
            return ans;
        }
    }

    return ans;
}

int main(){
    cin >> N >> X >> M;
    cin.ignore();

    ll ans;
    if(N <= M){
        ans = solver();
    } else {
        ans = solver2();
    }
    cout << ans << endl;

    return 0;
}

    

Measured memory_bytes: 5164
n,m = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(m)]

a.sort()
bc.sort(reverse=True, key=lambda x:x[1])
i = 0
ans = []
for b, c in bc:
    N = len(ans)
    for i in range(b):
        if N > n-1: break
        if a[N] < c:
            ans.append(c) 
            N += 1
        else: break
print(sum(ans) + sum(a[len(ans):]))

Measured memory_bytes: 32964
#include <stdio.h>
#include <string.h>

#define TAX(ret, val, tax) \
  ret = (val * 100) / tax; \
  if ( val > (ret * tax) / 100) ret++;

int main(void)
{
    long long A, B;
    long long ret = 0;
    long long tmp;
    long long tmp1_M, tmp1_m, tmp2_M, tmp2_m;
    int i;

    scanf("%ld %ld", &A, &B);

    TAX(tmp1_m, A, 8)
    for (i = 1; ; i++) {
        tmp = ((tmp1_m + i) * 8) / 100;
        if (tmp != A) {
            tmp1_M = tmp1_m + (i - 1);
            break;
        }
    }
    TAX(tmp2_m, B, 10)
    for (i = 1; ; i++) {
        tmp = ((tmp2_m + i) * 10) / 100;
        if (tmp != B) {
            tmp2_M = tmp2_m + (i - 1);
            break;
        }
    }
    if ((tmp1_M >= tmp2_m) && (tmp1_m <= tmp2_M)) {
        if (tmp1_m >= tmp2_m) ret = tmp1_m;
        else ret = tmp2_m;
    } else if ((tmp2_M >=tmp1_m) && (tmp2_m <= tmp1_M)) {
        if (tmp2_m >= tmp1_m) ret = tmp2_m;
        else ret = tmp1_m;
    } else {
        ret = -1;
    }

    printf("%ld", ret);

    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

const LL MOD = 1e9 + 7;

LL dp[10005][101][2] = {0};

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

    string s;
    LL d;
    cin>>s>>d;

    LL n = s.size();
    dp[0][0][1] = 1;
    REP(i,n){
        LL x = s[i] - '0';
        REP(j,d){
            for(LL k = 0; k < x; k++){
                dp[i+1][(j+k)%d][0] += dp[i][j][0] + dp[i][j][1] % MOD;
                dp[i+1][(j+k)%d][0] %= MOD;
            }
            dp[i+1][(j+x)%d][1] += dp[i][j][1];
            dp[i+1][(j+x)%d][1] %= MOD;
            for(LL k = x; k <= 9; k++){
                dp[i+1][(j+k)%d][0] += dp[i][j][0];
                dp[i+1][(j+k)%d][0] %= MOD;
            }
        }
    }

    PUTS((dp[n][0][0] + dp[n][0][1] + MOD - 1) % MOD);
}

Measured memory_bytes: 16000
#include <cstdio>
#include <algorithm>
using namespace std;
int item_list[100][2];
int solution_list[101][10001];
int select(int size, int weight_a)
{
	if (solution_list[size][weight_a] == -1)
	{
		if (size < 0 || weight_a < 0)
		{
			return 0;
		}
		if (size == 0 || weight_a == 0) 
		{
			solution_list[size][weight_a] = 0;
			return 0;
		}
		if (item_list[size - 1][1] > weight_a)
		{
			solution_list[size][weight_a] = select(size - 1, weight_a);
			return solution_list[size][weight_a];
		}
		else
		{
			int a, b;
			a = item_list[size - 1][0] + select(size - 1, weight_a - item_list[size - 1][1]);
			b = select(size - 1, weight_a);
			solution_list[size][weight_a] = (a > b) ? a : b;
			return solution_list[size][weight_a];
		}
	}
	else
	{
		return solution_list[size][weight_a];
	}
}

int main()
{
	fill(&solution_list[0][0], &solution_list[100][10001], -1);
	int N, W;
	scanf("%d%d", &N, &W);
	for (int i = 0; i < N; i++)
	{
		scanf("%d%d", &item_list[i][0], &item_list[i][1]);
	}
	printf("%d\n", select(N, W));
	return 0;
}


Measured memory_bytes: 6712
#include <iostream>


#include <stdlib.h>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <vector>
using namespace std;
#include <stdio.h>
#include <vector> 
#include <map> 
#include <algorithm>
#include <functional>
#include <algorithm>
#include <functional>
#include <array>
#include <iostream>

#include<iostream>
using namespace std;

std::vector< std::vector<int> > graph;
std::vector<int> c;


void rr(int root, int count) {
	if (count == 0){
		return;
	}
	for(const auto &a : graph[root]) {
		c[a] += count;

		rr(a, count);
	}
}

void eee(int root, int count) {
	c[root] += count;
	for (const auto &a : graph[root]) {
		eee(a, c[root]);
	}
}

int main()
{
	std::vector<int> a, b;
	std::vector<int> p, x;


	std::string s;
	int N, Q;
	cin >> N >> Q;



	graph.resize(N);
	c.resize(N);

	for (int i = 1; i < N; ++i) {
		graph[i].reserve(N);
	}

	for (int i = 1; i < N; ++i) {
		int aa, bb;
		cin >> aa >> bb;
		aa -= 1;
		bb -= 1;
		//a.push_back(aa);
		//b.push_back(bb);

		graph[std::min(aa, bb)].push_back(std::max(aa, bb));
	}

	p.resize(N);
	x.resize(N);
	for (int i = 0; i < Q; ++i) {
		int aa, bb;
		cin >> aa >> bb;

		aa -= 1;
		p[aa] += bb;

		c[aa] += bb;
	}

	//for (int i = 0; i < p.size(); ++i) {
	//	c[i] += p[i];
	//	rr(i, p[i]);
	//}
	eee(0, 0);

	printf("%d", c[0]);
	for (int i = 1; i < c.size(); ++i) {
		printf(" %d", c[i]);
	}
	printf("\n");


	return 0;
}



Measured memory_bytes: 832300
from collections import Counter

N = int(input())
V = input().split()
a = V[::2]
b = V[1::2]
h = int(N / 2)
ac = Counter(a)
bc = Counter(b)
ma = ac.most_common()
mb = bc.most_common()
if ma[0][0] == mb[0][0]:
  if len(ma) == len(mb) == 1:
    ans = h
  elif len(ma) == 1:
    ans = h - mb[1][1]
  elif len(mb) == 1:
    ans = h - ma[1][1]
  else:
    ans = min(2 * h - ma[0][1] - mb[1][1], 2 * h - mb[0][1] - ma[1][1])
else:
  ans = 2 * h - ma[0][1] - mb[0][1]
print(ans)

Measured memory_bytes: 25964
//三角関数はラジアンで使う。度数記法での引数は異なる結果になる。

#include <stdio.h>
#include <math.h>
#define MAX 100
#define PI 3.14159265359
typedef struct{
    double x, y;
}Point;

void koch( int n, Point p1, Point p2 );

int main(){
    int n;

    Point start_val = {0, 0};
    Point end_val   = {100, 0};
    scanf("%d", &n);
    printf("%f %f\n", start_val.x, start_val.y);
    koch(n, start_val, end_val);
    printf("%f %f\n", end_val.x, end_val.y);
    return 0;
}

void koch( int n, Point p1, Point p2 ){
    Point s, t, u;
    double rad = PI/3;

    if( n == 0 ) return ;
    //calculate
    s.x = (2*p1.x + 1*p2.x)/3;
    s.y = (2*p1.y + 1*p2.y)/3;
    t.x = (1*p1.x + 2*p2.x)/3;
    t.y = (1*p1.y + 2*p2.y)/3;
    u.x = (t.x-s.x) * cos(rad) - (t.y-s.y) * sin(rad) + s.x;
    u.y = (t.x-s.x) * sin(rad) + (t.y-s.y) * cos(rad) + s.y;
    
    //recursively
    koch(n-1, p1, s);
    printf("%f %f\n", s.x, s.y);
    koch(n-1, s, u);
    printf("%f %f\n", u.x, u.y);
    koch(n-1, u, t);
    printf("%f %f\n", t.x, t.y);
    koch(n-1, t, p2);
    return ;
}



Measured memory_bytes: 2148
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1;i <= n;i++){
    ans += i;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int a[2001][2001];
int s[2001][2001];
int S(int x, int y, int u, int v) {
	return s[u][v] - s[u][y] - s[x][v] + s[x][y];
}
int main() {
	int n, k, x, y, w = 0;
	char tmp[10];
	scanf("%d%d", &n, &k); k *= 2;
	for (int i = 1; i <= n; i++) {
		scanf("%d%d%s", &x, &y, tmp);
		x = x % k + 1; y = y % k + 1;
		if (tmp[0] == 'B') a[x][y]++;
		else {
			a[x][y]--;
			w++;
		}
	}
	for (int i = 1; i <= k; i++)for (int j = 1; j <= k; j++)
		s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
	int ans = 0;
	for (int i = 1; i <= k/2; i++) for (int j = 1; j <= k/2; j++) {
		int t = w + S(0, 0, i, j) + S(i, j, i+k/2, j+k/2) + S(i+k/2, j+k/2, k, k);
		t += S(0, j + k / 2, i, k) + S(i + k / 2, 0, k, j);
		if (t < n - t) t = n - t;
		if (ans < t) ans = t;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 31488
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

int main(void){
	uint64_t x;
	scanf("%"SCNu64, &x);
	uint64_t n=100;
	uint32_t i;
	for(i=0; n<x; i++){
		n+=n/100;
	}
	printf("%"PRIu32"\n", i);
}


Measured memory_bytes: 1732
class UnionFind:
    def __init__(self, n):
        # 負  : 根であることを示す。絶対値はランクを示す
        # 非負: 根でないことを示す。値は親を示す
        self.table = [-1] * n
 
    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            # 経路の圧縮
            self.table[x] = self._root(self.table[x])
            return self.table[x]
 
    def find(self, x, y):
        return self._root(x) == self._root(y)
 
    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        # ランクの取得
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2
 
 
if __name__ == '__main__':
    n,m=map(int,input().split())
    p=list(map(int,input().split()))
    g=UnionFind(n+1)
    for i in range(m):
        x,y=map(int,input().split())
        g.union(x,y)
    cnt=0
    l=[]*n
    for i,j in enumerate(p):
        if g.table[j]==-1:
            if i+1==j:
                cnt+=1
        else:
            if g.find(i+1,j):
                cnt+=1
    print(cnt)

Measured memory_bytes: 14452
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

s = ns()
ans = 0
if s[0] == '1':
    ans += 1
if s[1] == '1':
    ans += 1
if s[2] == '1':
    ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to;
};

int main() {
	string str;
	cin >> str;
	if (str == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return 0;
	}

	set<char> cou;
	rep(i, 'a', 'z' + 1) {
		cou.insert(i);
	}
	for (auto itr : str)
		cou.erase(itr);
	if (cou.size() == 0) {
		set<char> al;
		al.insert(str[25]);
		for (int i = 24; 0 <= i; i--) {
			if (str[i] < *al.rbegin()) {
				char to;
				for (auto itr : al) {
					if (str[i] < itr) {
						to = itr;
						break;
					}
				}
				str[i] = to;
				str = str.substr(0,i + 1);
				break;
			}
			al.insert(str[i]);
		}
	}
	else {
		str += *cou.begin();
	}

	cout << str << endl;
	return 0;
}

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

constexpr int INF = 1 << 30;

void solve() {
    int h, w;
    std::cin >> h >> w;

    std::vector<std::vector<int>> xss(h, std::vector<int>(w));
    for (auto& xs : xss) {
        for (auto& x : xs) {
            std::cin >> x;
        }
    }

    int ans = INF;
    for (int si = 0; si < h; ++si) {
        for (int sj = 0; sj < w; ++sj) {
            int sum = 0;
            for (int i = 0; i < h; ++i) {
                for (int j = 0; j < w; ++j) {
                    sum += std::min(std::abs(si - i), std::abs(sj - j)) * xss[i][j];
                }
            }
            ans = std::min(ans, sum);
        }
    }

    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}



Measured memory_bytes: 3228
#include <stdio.h>
#include <string.h>

int main() {
    int n;
    char str1[101], str2[101];
    int hanako = 0, tarou = 0;
    
    scanf("%d", &n);
    
    while (n--) {
        scanf("%s %s", str1, str2);
        
        if (strcmp(str1, str2) > 0){
            tarou += 3;
        }else if (strcmp(str1, str2) < 0){
            hanako += 3;
        }else {
            tarou++;
            hanako++;
        }
    }
    
    printf("%d %d\n", tarou, hanako);
    
    return 0;
}




Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <map>
#pragma GCC optimize("Ofast")
using namespace std;

int main() {
  int N;
  string s;
  map<string, int> m;
 
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> N;
  for(int i = 0; i < N; ++i) {
    cin >> s;
   	m[s] = 1;
  }
  cout << m.size() << "\n";
}

Measured memory_bytes: 19184
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

void solve(int n,int m){
    vector<vector<int>> a(m,vector<int>(1300));
    int r;
    cin>>r;
    rep(i,r){
        int t,x,y,s;
        cin>>t>>x>>y>>s;
        --y;
        if(s)++a[y][t];
        else --a[y][t];
    }
    rep(i,m)rep(j,1299){
        a[i][j+1]+=a[i][j];
    }
    rep(i,m)rep(j,1300){
        a[i][j]=min(1,a[i][j]);
    }
    rep(i,m)rep(j,1299){
        a[i][j+1]+=a[i][j];
    }
    int q;
    cin>>q;
    while(q--){
        int s,t,y;
        cin>>s>>t>>y;
        --y;
        cout<<a[y][t-1]-a[y][s-1]<<endl;
    }
}


int main(){
    int n,m;
    while(cin>>n>>m,n!=0)solve(n,m);
    return 0;
}


Measured memory_bytes: 52520
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <vector>
#define ll long long
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int main()
{
    int n,in;
    vector<int> p,x;
    cin >> n;

    REP(i,n){
        cin >> in;
        p.push_back(in);
        if(in == i+1) x.push_back(1);
        else x.push_back(0);
    }

    int cnt = 0;
    REP(i,n){
        if(x[i] == 1){
            x[i]--;x[i+1]--;
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1276
import java.util.Scanner;

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

        int n = sc.nextInt();
        int up = 0 - 1000001;
        int down = 1000001;
        long sum = 0;

        for(int i = 0; i < n; i++){
            int n_i = sc.nextInt();

            if(n_i > up){
                up = n_i;
            }

            if(n_i < down){
                down = n_i;
            }

            sum += n_i;
        }

        System.out.println(down + " " + up + " " + sum);
    }
}


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

int main() {
    string s;
    cin >> s;
    int n = s.size();

    bool flag = true;

    rep(i, n) {
        if(i%2==1 && s[i]=='R') {
            flag = false;
            break;
        }
        else if(i%2==0 && s[i]=='L') {
            flag = false;
            break;
        }
    }

    flag==true ? cout << "Yes" << endl : cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto nkq = readln.split.to!(int[]);
    auto N = nkq[0];
    auto K = nkq[1];
    auto Q = nkq[2];
    auto AS = readln.split.to!(int[]);

    auto res = long.max;
    foreach (x; AS) {
        auto as = AS.dup ~ 0;
        size_t i;
        long[] cs;
        foreach (j, a; as) {
            if (a < x) {
                if (j-i >= K) {
                    sort(as[i..j]);
                    foreach (k; i..j-K+1) cs ~= as[k];
                }
                i = j+1;
            }
        }
        if (cs.length >= Q) {
            sort(cs);
            res = min(res, cs[Q-1] - x);
        }
    }
    writeln(res);
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    
    for (int i = 1; i <= B; ++i) {
        if (A*i%B == C) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n, q;
    string s;
    while(cin>>s>>q){
    	n=s.size();
        ll ans=0;
        int x, f;
        bool l=0;
        char c[111];
        deque<char> v;
        for(int i=0; i<n; ++i){
        	v.push_back(s[i]);
        }
        for(int i=0; i<q; ++i){
            scanf("%d",&x);
            if(x==1){
            	l=!l;
            }
            else{
            	scanf("%d%s",&f,c);
            	if(l){
            		if(f==1){
            			v.push_back(c[0]);
            		}
            		else{
            			v.push_front(c[0]);
            		}
            	}
            	else{
            		if(f==2){
            			v.push_back(c[0]);
            		}
            		else{
            			v.push_front(c[0]);
            		}
            	}
            }
        }
        if(l){
        	reverse(v.begin(), v.end());
        }
        for(auto it:v){
        	printf("%c",it);
        }
        cout<<endl;
    }
  return 0;
}




Measured memory_bytes: 896
n = int(input())
x = list(map(int, input().split()))

min = 100 * 100 ** 2

for p in range(1, 101, 1):
    ttl = 0
    for i in x:
       ttl += (i - p) ** 2
    if ttl <= min:
        min = ttl

print(min)

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

using namespace std;

string SA, SB, SC;

int main() {
    cin >> SA >> SB >> SC;
    char c = SA.front();
    SA.erase(0, 1);
    while(true) {
        if(c == 'a') {
            if(SA.empty())
                break;
            c = SA.front();
            SA.erase(0, 1);
        } else if (c == 'b') {
            if(SB.empty())
                break;
            c = SB.front();
            SB.erase(0, 1);
        } else {
            if(SC.empty())
                break;
            c = SC.front();
            SC.erase(0, 1);
        }
    }
    cout << (char)(c - 32) << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <stdio.h>
int main(void){
    int i,swi1=0,swi2=0;
    char S[4];
    for(i=0;i<4;i++)
    scanf("%s",S);
    
    if( (S[0]=='0'&&S[1]!='0' )|| (S[0]=='1'&&(S[1]=='1')||S[1]=='2') )
    swi1=1;
    if( (S[2]=='0'&&S[3]!='0' )|| (S[2]=='1'&&(S[3]=='1')||S[3]=='2') )
    swi2=1;
  
   
    if(swi1==1&&swi2==1)
    printf("AMBIGUOUS");
     if(swi1==1&&swi2==0)
    printf("MMYY");
     if(swi1==0&&swi2==1)
    printf("YYMM");
     if(swi1==0&&swi2==0)
    printf("NA");
    
    return(0);
}


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

namespace test
{
    class Program
    {
        
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int N, Q;
            N = int.Parse(str[0]);
            Q = int.Parse(str[1]);
            int[] Data = new int[N + 1];
            string[] input;
            for(int a = 0; a < Q; a++)
            {
                input = Console.ReadLine().Split(' ');
                Data[int.Parse(input[0])]++;
                Data[int.Parse(input[1])]++;
            }

            for(int a = 0; a <= N; a++)
            {
                if(Data[a] % 2 == 1)
                {
                    Console.WriteLine("NO");
                    break;
                }
                if(a == N)
                {
                    Console.WriteLine("YES");
                    break;
                }
            }

        }
    }
}

Measured memory_bytes: 15328
N = int(input())
A = [[] for i in range(N)]

for i in range(N):
  a = int(input())
  for j in range(a):
    A[i].append(tuple(map(int, input().split())))

ans = 0
for bits in range(2**N):
  l = [0] * N
  for i in range(N):
    l[i] = (bits >> i) % 2

  fail = False
  for i in range(N):
    if fail: break
    if l[i] == 0: continue # 不親切はパス
    for x, y in A[i]:
      if y != l[x-1]:
        fail = True
        break
  else:
    if not fail:
      ans = max(ans, sum(l))

print(ans)

Measured memory_bytes: 3064
def main()->None:
    N, A, B = map(int, input().split())
    diff = B - A - 1 # A,Bが初期位置にある時の間のマス目の数
    if diff % 2 == 0:
        print("Borys")

    else:
        print("Alice")


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#define ll long long
using namespace std;
int main(){
     int P,Q,R;
     int temp;
     cin >> P >> Q >> R;
     if(Q<P){
          temp = Q;
          Q = P;
          P = temp;
     }
     if(R<Q){
          temp = R;
          R = Q;
          Q = temp;
     }
     if(Q<P){
          temp = Q;
          Q = P;
          P = temp;
     }
     cout << P+Q << endl;
     return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
LL facctorialMethod(int k);
int main(){
    string s,t;
    cin >> s;
    cin >> t;
    if(s.substr(0,s.size()) == t.substr(0,t.size()-1)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i,n,s) for (int i = (s); i < (n); i++)
#define SIZE 50
using namespace std;
typedef long long int LL;

LL MOD;
int H, W, N, C, m[SIZE][SIZE];

int inOut(int x1, int y1, int x2, int y2) {
	int res;
	cout << "? " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
	cin >> res;
	return res;
}

int divide(int n1, int n2) {
	int r = 1;
	while (1) {
		if (r*2 >= n2 - n1 + 1) break;
		r <<= 1;
	}
	return r + n1 - 1;
}

void _f(int x1, int y1, int x2, int y2, int n) {
	if ((x2-x1+1)*(y2-y1+1) == n) {
		for(int i = x1; i < x2 + 1; i++) {
			for(int j = y1; j < y2 + 1; j++) {
				m[i][j] = 1;
			}
		}
		return;
	}
	if (x1 == x2 && y1 == y2) {
		m[x1][y1] = inOut(x1, y1, x1, y1);
		return;
	}
	if (x2 - x1 > y2 - y1) {
		int _x = divide(x1, x2);
		int r = inOut(x1, y1, _x, y2);
		if (r != 0) _f(x1, y1, _x, y2, r);
		if (r != n) _f(_x+1, y1, x2, y2, n-r);
	} else {
		int _y = divide(y1, y2);
		int r = inOut(x1, y1, x2, _y);
		if (r != 0) _f(x1, y1, x2, _y, r);
		if (r != n) _f(x1, _y+1, x2, y2, n-r);
	}
}

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

	cin >> H >> W >> N >> MOD;

	memset(m, 0, sizeof(m));
/*
	int idx = 0;
	while (N) {
		int i = idx/W, j = idx%W;
		cout << "? " << i << " " << j << " " << i << " " << j << endl;
		cin >> m[i][j];
		if (m[i][j] > 0) {
			N--;
		}
		idx++;
	}
*/
	_f(0, 0, H-1, W-1, N);

	LL res = 0, p = 1;
	REP(i, H, 0) {
		REP(j, W, 0) {
			res = (res + p * m[i][j] % MOD) % MOD;
			p = p * 2 % MOD;
		}
	}
	cout << "! " << res << endl;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {

	public static Character[] acgt = { 'A', 'C', 'G', 'T' };

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		char[] strArray = scanner.nextLine().toCharArray();

		int max = 0;
		int count = 0;

		for (char s : strArray) {
			if (isAcgt(s)) {
				count++;
			} else {
				if (max < count) {
					max = count;
				}
				count = 0;
			}
		}
		if (max < count) {
			max = count;
		}
		System.out.println(max);
		scanner.close();
	}

	private static boolean isAcgt(char param) {

		for (char c : acgt) {
			if (param == c) {
				return true;
			}
		}
		return false;
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int N, A, B; cin >> N;
    vector<int> a;
    A = B = 0;
    for (int i = 0; i < N; i++)
    {
        int ai; cin >> ai;
        a.push_back(ai);
    }
    sort(a.begin(), a.end(), greater<int>());
    for (int j = 0; j < N; j++)
    {
        if (j%2==0) A += a[j];
        else B += a[j];
    }
    cout << (A- B) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int n = String.valueOf(N).length();
        int K = sc.nextInt();
        int ans = 0;
        boolean c = true;
        boolean[] D = new boolean[10];
        Arrays.fill(D, false);
        for (int i = 0; i < K; i++) {
            int a=sc.nextInt();
            D[a] = true;
        }
        lavel:
        for (int i = N;; i++) {
            if(i>=Math.pow(10,n)){
                n++;
            }
            for (int j = 0; j < n; j++) {
                if (D[i / (int) Math.pow(10, j) % 10]) {
                    continue lavel;
                }
            }
                System.out.println(i);
                return;
        }
    }
}

Measured memory_bytes: 23764
import java.io.IOException;
import java.util.Scanner;

public class Main {

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

		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();

		int ans = A + B;

		if (ans >= 24) {
			ans -= 24;
		}

		System.out.println(ans);
	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


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

using namespace std;

typedef long long LL;

const int NMAX = 2e5;

int N;
int h[NMAX + 5], a[NMAX + 5];

class SegmentTree
{
    public:
    LL aint[4 * NMAX + 5];
    int pos, sti, dri;
    LL ans, val;

    void update(int nod, int st, int dr)
    {
        if(st == dr)
        {
            aint[nod] = max(aint[nod], val);
            return;
        }

        int mij = st + (dr - st) / 2;
        if(pos <= mij)  update(nod * 2, st, mij);
        else    update(nod * 2 + 1, mij + 1, dr);
        aint[nod] = max(aint[nod * 2], aint[nod * 2 + 1]);
    }

    LL query(int nod, int st, int dr)
    {
        if(sti <= st && dr <= dri)
        {
            ans = max(ans, aint[nod]);
            return 0;
        }
        int mij = st + (dr - st) / 2;
        if(sti <= mij)  query(nod * 2, st, mij);
        if(mij < dri)    query(nod * 2 + 1, mij + 1, dr);
        return 0;
    }

    void update(int _pos, LL _val)
    {
        pos = _pos, val = _val;
        update(1, 1, N);
    }

    LL query(int st, int dr)
    {
        ans = 0;
        sti = st, dri = dr;
        query(1, 1, N);
        return ans;
    }

}aint;

int main()
{
    //freopen("1.in", "r", stdin);

    cin >> N;
    for(int i = 1; i <= N; i++) cin >> h[i];
    for(int i = 1; i <= N; i++) cin >> a[i];

    for(int i = 1; i <= N; i++)
    {
        LL val = aint.query(1, h[i]);
        aint.update(h[i], val + a[i]);
    }
    cout << aint.query(1, N) << '\n';
    exit(0);
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define loop(i, a) for (int i = 0; i < a; i++)
#define revloop(i, a) for (int i = a-1; i > -1; i--)
#define show(a) cout << a << "\n"
#define MOD 1000000007
#define V vector
#define S set
#define P pair
#define M map
#define PQ priority_queue

int main() {
    //freopen("inputs.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    int a = n, b = 0;
    while (n) {
        b*=10;
        b+=n%10;
        n/=10;
    }
    (a == b)? show("Yes"):show("No");
    return 0;
}


Measured memory_bytes: 256
<?php
  $n = trim(fgets(STDIN)) ;
$b = explode(' ',trim(fgets(STDIN))) ;
$sum=$b[0]+$b[$n-2];
for($i=0;$i<$n-2;$i++){
  $sum += min($b[$i],$b[$i+1]) ;
}
echo $sum ;

Measured memory_bytes: 3576
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			//Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//string s = Console.ReadLine();
			int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int[] hp = new int[100];
			for (int i = 0; i < n; i++) {
				for (int j = 1; j <= 100; j++) {
					hp[j - 1] += (x[i] - j) * (x[i] - j);
				}
			}
			//System.Diagnostics.Debug.WriteLine(string.Join(",", hp));
			Console.WriteLine(hp.Min());


			//Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 11348