akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	private static final char UP = 'U';
	private static final char DOWN = 'D';
	private static final char LEFT = 'L';
	private static final char RIGHT = 'R';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int sx = scanner.nextInt();
			int sy = scanner.nextInt();
			int tx = scanner.nextInt();
			int ty = scanner.nextInt();
			int x = tx - sx, y = ty - sy;
			StringBuilder sb = new StringBuilder();
			IntStream.range(0, y).forEach(i -> sb.append(UP));
			IntStream.range(0, x).forEach(i -> sb.append(RIGHT));
			IntStream.range(0, y).forEach(i -> sb.append(DOWN));
			IntStream.range(0, x).forEach(i -> sb.append(LEFT));
			sb.append(LEFT);
			IntStream.range(0, y + 1).forEach(i -> sb.append(UP));
			IntStream.range(0, x + 1).forEach(i -> sb.append(RIGHT));
			sb.append(DOWN);
			sb.append(RIGHT);
			IntStream.range(0, y + 1).forEach(i -> sb.append(DOWN));
			IntStream.range(0, x + 1).forEach(i -> sb.append(LEFT));
			sb.append(UP);
			System.out.println(sb.toString());
		}
	}
}


Measured memory_bytes: 27348
n=int(input())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
c=list(map(int, input().split()))
ans=sum(b)
for i in range(n-1):
    if a[i+1] - a[i] == 1:
        ans += c[a[i]-1]
print(ans)

Measured memory_bytes: 38256
n, m = map(int, input().split())

c = list(map(int, input().split()))

dp = [[float('inf')]*(n+1) for _ in range(m+1)]
dp[0][0] = 0

for i in range(m):
    for j in range(n+1):
        if j - c[i] >= 0:
            dp[i+1][j] = min(dp[i+1][j], dp[i+1][j-c[i]] + 1)
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])

print(dp[m][n])


Measured memory_bytes: 43732
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,x = map(int, input().split())
    a = list(map(int, input().split()))

    if n == 1:
        print(abs(a[0] - x))
        exit()

    for i in range(n):
        a[i] = abs(a[i] - x)
    
    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    def gcd_group(arr):
        g = gcd(arr[0], arr[1])
        for i in range(2, len(arr)):
            g = gcd(g, arr[i])
        return g
    
    def lcm(a, b):
        g = gcd(a, b)
        return (a*b)//g
    
    def lcm_group(arr):
        l = lcm(arr[0], arr[1])
        for i in range(2, len(arr)):
            l = lcm(l, arr[i])
        return l
    
    print(gcd_group(a))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 58736
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#define RG register
#define IL inline
#define inf 2147483640
#define LL long long
#define db double
#define N 100005
#define int long long
using namespace std;
IL int gi()
{
	RG int res=0,w=1;
	RG char ch;
	for(ch=getchar();(ch<'0'||ch>'9')&&ch!='-';ch=getchar());
	if(ch=='-') w=-1,ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) res=10*res+ch-48;
	return res*w;
}
int x,n;
struct node{int l,r,t,g,b,d;} tim[N];
int sum[N];
main()
{
	//freopen("4.in","r",stdin);
	//freopen("4.out","w",stdout);
	x=gi(); n=gi();
	for(RG int i=1;i<=n;++i)
		{
			tim[i].d=gi();
			tim[i].t=tim[i].d-tim[i-1].d;
			tim[i].g=(i&1)?(-1):(1);
			sum[i]=sum[i-1]+tim[i].g*tim[i].t;
		}
	tim[0].l=0,tim[0].r=x,tim[0].b=0;
	for(RG int i=1;i<=n;++i)
		{
			if(tim[i-1].l==tim[i-1].r) {
				if(tim[i].g==1) tim[i].l=tim[i].r=min(x,tim[i-1].l+tim[i].t);
				else tim[i].l=tim[i].r=max((LL)0,tim[i-1].l-tim[i].t);
				continue;
			}
			if(tim[i].g==1)
				{
					RG int l=tim[i-1].l,r=tim[i-1].r;
					if(r+tim[i].t<x) tim[i].r=r+tim[i].t,tim[i].l=l+tim[i].t,tim[i].b=tim[i-1].b;
					else if(l+tim[i].t>=x) tim[i].l=tim[i].r=x;
					else
						{
							tim[i].b=tim[i-1].b;
							tim[i].l=l+tim[i].t;
							tim[i].r=x;
						}
				}
			else
				{
					RG int l=tim[i-1].l,r=tim[i-1].r;
					if(l-tim[i].t>0) tim[i].r=r-tim[i].t,tim[i].l=l-tim[i].t,tim[i].b=tim[i-1].b;
					else if(r-tim[i].t<=0) tim[i].l=tim[i].r=0;
					else
						{
							tim[i].b=tim[i-1].b+(tim[i].t-l);
							tim[i].l=0,tim[i].r=r-tim[i].t;
						}
				}
		}
	RG int tt,aa,dd,bas;
	for(RG int q=gi();q;--q)
		{
			tt=gi(),aa=gi();
			RG int le=0,ri=n;
			RG int mid;
			while(le<ri)
				{
					mid=((le+ri)>>1)+1;
					if(tim[mid].d<=tt) le=mid;
					else ri=mid-1;
				}
			        dd=tt-tim[le].d;
					if(aa>=tim[le].b+tim[le].r-tim[le].l) bas=tim[le].r;
					else if(aa<=tim[le].b) bas=tim[le].l;
					else bas=sum[le]+aa;
					printf("%lld\n",(le&1)?min(x,bas+dd):max((LL)0,bas-dd));
		}
	//fclose(stdin);fclose(stdout);
	return 0;
}

Measured memory_bytes: 6656
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int main()
{
    map<int,int>p;
    int a[1000],i,j,k,s=0,n;
   cin>>n;
   for(i=0;i<n;i++)cin>>a[i];
   sort(a,a+n);
    for(i=0;i<n-2;i++)
    {
        for(j=i+1;j<n-1;j++)
        {
            for(k=j+1;k<n;k++)
            {
                
                if (a[i]+a[j]>a[k] && a[i]!=a[j] && a[j]!=a[k]){//cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<endl;
                s++;}
                
            }
        }
    }cout<<s;
}
        

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

int main() {
  int A,B,K;
    cin>>A>>B>>K;
  int sum=0;
  int M=min(A,B);
  for(int i=M;1<=i;i--){
    if(A%i==0&&B%i==0){
     sum+=1;
    }
    if(K<=sum){
      cout<<i<<endl;
      break;
    }
  }
}


Measured memory_bytes: 256
inp = [int(f) for f in input().split()]
if inp[0] > inp[2]:
    if inp[1] < inp[2]:
        print('Yes')
    else:
        print('No')
elif inp[0] < inp[2]:
    if inp[1] > inp[2]:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  static ll par[12] = {0,2,0,1,0,1,0,0,1,0,1,0};
  int x,y;
  cin >> x >> y;
  x--, y--;
  if(par[x]==par[y]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD (int)(1e9+7)

using namespace std;

vector<int> adj[100005];
int mem[100005][2];
int n;

int go(int x,int l,int pa=-1)
{
	if(mem[x][l]!=-1) return mem[x][l];
	mem[x][l]=1;
	long long bl=(l==0),wh=1;
	for(int i:adj[x])
	{
		if(i==pa) continue;
		wh*=go(i,0,x);
		wh%=MOD;
		bl*=go(i,1,x);
		bl%=MOD;
	}
	//cout << x << " " << l << " " << bl << " " << wh << endl;
	return mem[x][l]=(wh+bl)%MOD;
}

int main()
{
	cin >> n;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin >> x >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	memset(mem,-1,sizeof mem);
	cout << go(1,0) << endl;
}

Measured memory_bytes: 14848
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        String s = in.next();

        int a = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '0') {
                a++;
            }
        }

        int m = Math.min(a, s.length() - a);

        out.println(m * 2);
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

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

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

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

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 23252
// https://atcoder.jp/contests/dp/tasks/dp_b
#include<iostream>
#include <cstdlib>

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n,k;
	cin >> n >> k;
	int height[n];
	for(int i=0;i<n;i++)
		cin >> height[i];
	int arr[n];
	for(int i=1;i<n;i++)
		arr[i] = INT_MAX;
	arr[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(i+j>=n)
				break;
			if(arr[i] + abs(height[i]-height[i+j]) < arr[i+j])
				arr[i+j] = arr[i] + abs(height[i]-height[i+j]);
		}
	}
	cout << arr[n-1] << endl;
	return 0;
}

Measured memory_bytes: 3932
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  for(string s; cin >> s;) {
    if(s == "0") break;

    int n = s.size();
    rep(i, n) s[i] -= '0';

    static int dp[2][11];
    zero(dp);

    int ans = 0;

    rep(i, n) {
      zero(dp[(i+1)&1]);
      if(s[i] != 0) dp[(i+1)&1][(int)s[i]] ++;
      rep(j, 11) {
        int nj = (j * 10 + s[i]) % 11;
        dp[(i+1)&1][nj] += dp[i&1][j];
      }
      ans += dp[(i+1)&1][0];
    }

    cout << ans << endl;

  }
  
  return 0;
}

Measured memory_bytes: 3168
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

ll dp[101][101][2];//dp[i][j][k]...i枚目のディスクでjcmとなるディスクの積み方の総数（k=0なら一番上は黒）

int main()
{
	int l,k;
	cin>>l>>k;
	fill(dp[0][0],dp[101][0],0);
	dp[1][1][0]=1;
	dp[1][k][0]=1;
	for(int i=1;i<100;i++)
	{
		for(int j=0;j<101;j++)
		{
			//白を積む
			if(dp[i][j][0]>0 && j+1<101)
				dp[i+1][j+1][1]+=dp[i][j][0];
			//黒を積む
			if(dp[i][j][1]>0)
			{
				if(j+k<101)
					dp[i+1][j+k][0]+=dp[i][j][1];
				if(j+1<101)
					dp[i+1][j+1][0]+=dp[i][j][1];
			}
		}
	}

	ll ans=0;
	//解答を調べる
	for(int i=1;i<101;i++)
	{
		for(int j=1;j<l+1;j++)
			ans+=dp[i][j][0];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3252
#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++)

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

  vector<int> arr(n + 1, 0);

  rep(i, m)
  {
    cin >> a >> b;
    arr[a]++;
    arr[b]++;
  }
  rep2(i, 1, n + 1)
  {
    cout << arr[i] << endl;
  }
}

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

int main(){
 int n; cin >> n;
 if(n<10)cout << n << endl;
 else if(n>=10 && n<100) cout << '9' << endl;
 else if(n>=100 && n<1000) cout << 9+n-99 << endl;
 else if(n>=1000 && n<10000) cout << "909" << endl;
 else if(n>=10000 && n<100000) cout << 909+n-9999 << endl;
 else cout << "90909" << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
char c[ 100001 ];
int main( )
{
	scanf( "%s", c );
	int n = strlen( c );
	int ans = 0;
	for( int i = 1; i < n; ++i )
		ans += c[ i ] != c[ i - 1 ];
	printf( "%d", ans ); 
	return 0;
}

Measured memory_bytes: 3824
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e9;
long long A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,S,T,U,V,W,x,y,z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;

template <std::int_fast64_t Modulus> class modint {
  using u64 = std::int_fast64_t;
public:
  u64 a;
  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
#pragma endregion

std::vector<int> manacher(const std::string &s) {
    int n = s.size();
    std::vector<int> rad(n);
    int c = 0;
    for (int r = 0; r < n; ++r) {
        int l = c - (r - c);
        if (r + rad[l] < c + rad[c]) {
            rad[r] = rad[l];
        } else {
            int rr = c + rad[c];
            int rl = r - (rr - r);
            while (rl >= 0 && rr < n && s[rl] == s[rr]) ++rr, --rl;
            rad[r] = rr - r;
            c = r;
        }
    }
    return rad;
}

std::string insert_dollar(const std::string &s) {
    int n = s.size();
    std::string res(n * 2 + 1, '$');
    for (int i = 0; i < n; ++i) {
        res[i * 2 + 1] = s[i];
    }
    return res;
}

bool is_palindrome(int l, int r, const std::vector<int> &rad) {
    l = l * 2 + 1;
    r = (r - 1) * 2 + 1;
    int c = (l + r) / 2;
    return r < c + rad[c];
}
int main() {
  string s;
  bool flag = true;
  cin >> s;
  int len = s.size();
  rep(i, len){
    flag &= (s[i] == s[len - i - 1]);
  }
      cout << endl;
  rep(i, len/2){
    flag &= (s[i] == s[len/2 - i - 1]);
    flag &= (s[len/2 + i + 1] == s[len - i - 1]);
  }
  if(flag) cout << "Yes";
  else cout << "No";
} 



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

int main(){
    int N;
    cin >> N;
    int cnt = 0;
    int p[N];
    rep2(i, 2, N+1){
        bool check = true;
        rep2(j, 2, i){
            if(j*j > i){
                break;
            }
            else if(i % j == 0){
                check = false;
                break;
            }
        }
        if(check){
            p[cnt] = i;
            cnt++;
        }
    }
    int num[N+1][cnt];
    rep2(i, 1, N+1){
        int I = i;
        rep(j, cnt){
            num[i][j] = 0;
            while(I % p[j] == 0){
                num[i][j]++;
                I /= p[j];
            }
        }
    }
    int total[cnt];
    fill_n(total, cnt, 0);
    rep2(i, 1, N+1){
        rep(j, cnt){
            total[j] += num[i][j]; 
        }
    }
    int ans = 0;
    rep(i, cnt){
        if(total[i] >= 74){
            ans++;
        }
        if(total[i] >= 24){
            rep(j, cnt){
                if(j != i && total[j] >= 2){
                    ans++;
                }
            }
        }
        if(total[i] >= 14){
            rep(j, cnt){
                if(j != i && total[j] >= 4){
                    ans++;
                }
            }
        }
        if(total[i] >= 2){
            int count = 0;
            rep(j, cnt){
                if(j != i && total[j] >= 4){
                    count++;
                }
            }
            ans += count*(count-1)/2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);

call($n);

function call($n)
{
    for ($i = 1; $i <= $n; $i++) {
        $x = $i;

        if (0 == $x % 3) {
            echo " $i";
            continue;
        }

        while ($x > 0) {
            if (3 == $x % 10) {
                echo " $i";
                break;
            }

            $x = floor($x / 10);
        }
    }

    echo "\n";
}

Measured memory_bytes: 6580
x = list(map(int,input().split()))
y = list(map(int,input().split()))
z = list(map(int,input().split()))

n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
  for j in range(3):
    if x[j] == a[i]:
      x[j] = 0
    if y[j] == a[i]:
      y[j] = 0
    if z[j] == a[i]:
      z[j] = 0
      
#print(x),print(y),print(z)
bingo = False

if max(x) == 0 or max(y) == 0 or max(z) == 0:
  bingo = True

for i in range(3):
  if x[i] == 0 and y[i] == 0 and z[i] == 0:
    bingo = True
    break

if x[0] == 0 and y[1] == 0 and z[2] == 0:
  bingo = True

if x[2] == 0 and y[1] == 0 and z[0] == 0:
  bingo = True

#print(bingo)
if bingo:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    int a, b, c, d, s; cin >> s;
    a = s /1000 % 10, b = s / 100 % 10, c = s / 10 % 10, d = s % 10;
    if(a+b+c+d==7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << ln;
    else if(a+b+c-d==7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << ln;
    else if(a+b-c+d==7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << ln;
    else if(a-b+c+d==7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << ln;
    else if(a-b-c+d==7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << ln;
    else if(a-b+c-d==7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << ln;
    else if(a+b-c-d==7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << ln;
    else if(a-b-c-d==7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << ln;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);
int change(string s){
    int k=0;int ki=1;
    reverse(s.begin(),s.end());
    rep(i,s.size()){
        k+=(int(s[i]-'0'))*ki;
        ki*=10;
    }
    return k;
}
int main() {
    int n;
    cin>>n;
    rep(nn,n){
        string s;
        cin>>s;
        vector<int> v;
        int si=0;
        while(si<s.size()){
            if(s[si]=='['){v.push_back(-1);si++;}
            else if(s[si]==']'){v.push_back(-2);si++;}
            else{
                string num;
                while(s[si]!=']'&&s[si]!='[') {
                    num+=s[si];
                    si++;
                }
                v.push_back(change(num));

                }
        }


        stack<int> st;
        st.push(v[0]);
        for(int i=1;i<v.size();i++){
           if(v[i]!=-2){
               st.push(v[i]);
           }else{
               vector<int> sen;
               while(true){
                   int k=st.top();st.pop();
                   if(k!=-1)sen.push_back(k);
                   else break;
               }
               sort(sen.begin(),sen.end());
               int k1=0;
               for(int j=0;j<(sen.size()+1)/2;j++){
                   if(sen.size()==1){k1+=(sen[j]+1)/2;}
                   else{k1+=sen[j];}
               }
               st.push(k1);
               //cout<<k1<<endl;
           }
        }

        cout<<st.top()<<endl;




     
    }



    return 0;
}




Measured memory_bytes: 3336
#include <iostream>
#include <algorithm>

using namespace std;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define REPR(i,n) for (int i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)

const int MAX = 710;
int G[MAX][MAX];
int group[MAX];
int groupCount[2*MAX];
int N, M;
bool dp[MAX];

bool dfs(int n, int g) {
    group[n] = g;
    bool res = true;
    REP (i, N) if (i != n) {
        if (G[n][i]) {
            if (group[i] == g) return false;
            if (group[i] == -1) res &= dfs(i, g^1);
        }
    }
    return res;
}

int main() {
    cin >> N >> M;

    REP (i, N) REP (j, N) G[i][j] = 1;
    REP (i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a][b] = G[b][a] = 0;
    }

    int count = 0;
    REP (i, N) group[i] = -1;
    REP (i, N) {
        if (group[i] == -1) {
            if (!dfs(i, count*2)) {
                cout << -1 << endl;
                return 0;
            }
            count++;
        }
        groupCount[group[i]]++;
    }

    dp[0] = true;
    REP (g, count) {
        REPR (i, MAX) if (dp[i]) {
            dp[i] = false;
            dp[i+groupCount[g*2]] = dp[i+groupCount[g*2+1]] = true;
        }
    }
    int ans = 1e9;
    REP (t, MAX) if (dp[t]) {
        int h = N-t;
        ans = min(ans, (t*(t-1)+h*(h-1))/2);
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> a(n+1);
    rep(i, n+1) cin>>a[i];
    vector<ll> b(n);
    rep(i, n) cin>>b[i];
    ll ans = 0;
    rep(i, n){
        if (a[i] >= b[i]){ 
            ans += b[i];
        }    
        else {
            if (a[i] + a[i+1] >= b[i]){ 
                ans += b[i];
                a[i+1] -= b[i] - a[i];
            }
            else{ 
                ans += a[i] + a[i+1];
                a[i+1] -= a[i+1];
            }
        }
    }
    cout << ans <<endl;
    return 0;
}

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

#define ALL(a)  a.begin(),a.end()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define debug(x) cerr << #x << ": " << x << endl

using LL = long long; template<class T> using V = vector<T>;

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

	int N, K;
	while (cin >> N >> K, N) {
		V<int>a(K);
		FOR(i, 0, K) {
			cin >> a[i];
		}
		SORT(a);
		int has = 0;
		if (a[0] == 0)has = 1;
		int ans = 0;
		using PII = pair<int, int>;
		V<PII>v;
		int s = has;
		FOR(i, has, K - 1) {
			if (a[i] + 1 == a[i + 1]) {
				continue;
			}
			else {
				v.push_back(PII(s, i));
				ans = max(ans, i - s + 1);
				s = i + 1;
			}
		}

		v.push_back(PII(s, K - 1));
		if (has)FOR(i, 0, SZ(v) - 1) {
			int LE = v[i].second;
			int RS = v[i + 1].first;
			if (a[LE] + 2 == a[RS]) {
				ans = max(ans, v[i + 1].second - v[i].first + 2);
			}
		}
		cout << ans << endl;
	}
	return 0;
}//


Measured memory_bytes: 3456
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


N = int(input())
A = [int(input()) for _ in range(N)]

max_a = max(A)
max_idx = [i for i, x in enumerate(A) if x == max_a]

if len(max_idx) > 1:
    for i in range(N):
        print(max_a)
    exit()
else:
    for i in max_idx:
        A[i] = NIL
    second_max = max(A)

    for i in range(N):
        if i in max_idx:
            print(second_max)
        else:
            print(max_a)


Measured memory_bytes: 62428
s=int(input())
S=[]
for i in range(1000000):
  S.append(s)
  if s%2==0:
    s = s/2
    if len(S) != len(set(S)):
        print(i+1)
        exit()
  else:
    s = 3*s +1
    if len(S) != len(set(S)):
        print(i+1)
        exit()

Measured memory_bytes: 3060
import java.util.HashMap;
import java.util.Scanner;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by hirai on 2016/08/30.
 */
public class Main {

    /*
    public static final void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println((scanner.nextInt()
                + scanner.nextInt()
                + scanner.nextInt())
                + " "
                + scanner.next());
    }
    */
    /*
    public static final void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int k = scanner.nextInt();
        final int x = scanner.nextInt();
        final int y = scanner.nextInt();

        int sum = 0;
        for (int i = 0; i < n; i++) {
            if (i < k) {
                sum += x;
            } else {
                sum += y;
            }
        }
        System.out.println(sum);
    }
    */
    public static final void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        final String line = scanner.next();
        HashMap<Character, AtomicInteger> map = new HashMap<>();
        for(char c : line.toCharArray()){
            if(map.containsKey(c)){
                map.get(c).incrementAndGet();
            }else{
                map.put(c, new AtomicInteger(1));
            }
        }
        if(map.entrySet()
                .stream()
                .filter(entry -> entry.getValue().get() % 2 == 0)
                .count() == map.size()){
            System.out.print("Yes");
        }else{
            System.out.print("No");
        }
    }
}


Measured memory_bytes: 15568
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define REP(i,a) FOR(i,0,(int)(a)-1)
#define reset(a,b) memset(a,b,sizeof(a))
#define BUG(x) cout << #x << " = " << x << endl
#define PR(x,a,b) {cout << #x << " = "; FOR (_,a,b) cout << x[_] << ' '; cout << endl;}
#define CON(x) {cout << #x << " = "; for(auto i:x) cout << i << ' '; cout << endl;}
#define mod 1000000007
#define pi acos(-1)
#define eps 0.00000001
#define pb push_back
#define sqr(x) (x) * (x)
#define _1 first
#define _2 second

int n, canRow[555], need[555];
string lis[555];

int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  int ans1 = mod;
  int ans2 = 0;
  bool flag = false;
  REP (i, n) {
  	cin >> lis[i];
  	need[i] = n;
  	REP (j, n) if (lis[i][j] == '#') {
  		canRow[j] = 1;
  		need[i]--;
  	}
  	if (!need[i]) ans1 = 0;
  	if (need[i] != n) ans1 = min(ans1, need[i] + 1);
  }
	REP (i, n) if (canRow[i]) ans1 = min(ans1, need[i]);
  if (ans1 == mod) {
  	cout << -1;
  	return 0;
  }
  ans2 = n;
  REP (j, n) {
  	flag = false;
  	REP (i, n) if (lis[i][j] == '.') flag = true;
  	if (!flag) ans2--;
  }
  // BUG(ans1);
  cout << ans1 + ans2;
}

Measured memory_bytes: 512
def insertionsort(x):
    x = list(map(int, x))
    for i in range(len(x)):
        for k in range(i, 0, -1):
            if x[k-1] > x[k]:
                x[k-1], x[k] = x[k], x[k-1]
        print(" ".join(map(str, x)))


if __name__ == "__main__":
    input()
    insertionsort(input().split(" "))

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

const int dx[] = { -1 , 0 , 0 , 1 } ;
const int dy[] = { 0 , -1 , 1 , 0 } ;

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    ll temp , n ;
    cin >> temp >> n ;

    ll s = 0 ;
    for ( int i=0 ; i < n ; i ++ )
    {
        ll t ;
        cin >> t ;

        s += t ;
    }

    if ( s >= temp )
        cout << "Yes" ;
    else
        cout << "No" ;

    line ;
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0){
		return 1;
	}else if(b%2==0){
		ll memo = mpow(a,b/2);
		return memo*memo%MOD;
	}else{
		return mpow(a,b-1) * a % MOD;
	}
}

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

bool memo[52][52], memo2[52][52];
bool ok[52][52];
void init(int n){
	rep(i,n){
		rep(j,52){
			memo[i][j] = ok[i][j];
			memo2[i][j] = false;
		}
	}
}

bool can(ll k, vector<int> A, vector<int> B){
	int n = A.size();
	init(n);
	rep(i,n){
		int a = A[i];
		memo[i][a] = true;
	}

	REPS(waru, k){
		rep(i,n){
			rep(j,52){
				if(memo[i][j]){
					memo2[i][j] = true;
					memo2[i][j%waru] = true;
				}
			}
		}
		rep(i,n){
			rep(j,52){
				memo[i][j] = memo2[i][j];
				memo2[i][j] = false;
			}
		}
	}
	rep(i,n){
		if(!memo[i][B[i]]){
			return false;
		}
	}
	return true;
}

int main(void){
	int n,a,b;
	cin>>n;
	vector<int> A,B;
	rep(i,n){
		cin>>a;
		A.push_back(a);
	}
	rep(i,n){
		cin>>b;
		B.push_back(b);
	}
	rep(i,n){
		rep(j,52){
			ok[i][j] = false;
		}
	}
	rep(i,n){
		ok[i][A[i]] = true;
	}
	//cout<<"hoge"<<endl;
	ll ans = 0;
	ll k = 0;
	ll max_k = LINF;
	while(k < min((ll)51, max_k)){
		//cout<<k<<endl;
		if(can(k,A,B)){
			max_k = k;
			if(k==0) break;
			ll ok2[52][52];
			rep(i,n){
				rep(j,52){
					ok2[i][j] = ok[i][j];
				}
			}
			rep(i,n){
				rep(j,52){
					if(ok2[i][j]){
						ok[i][j%k] = true;
					}
				}
			}
			ans += pow(2,k);

			k = 0;
			//cout<<k<<endl;
			continue;
		}
		/*if(ans == 160){
			rep(i,n){
				rep(j,52){
					cout<<ok[i][j];
				}
				cout<<endl;
			}
		}*/
		//cout<<k<<endl;
		k++;
	}
	cout<<(max_k==LINF?-1:ans)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;

typedef complex<double> P;

bool operator<(const P &a, const P &b){
    return real(a) != real(b) ? real(a) < real (b) : imag(a) < imag(b);
}

bool predication(const P &a, const P &b){
    return real(a) != real(b) ? real(a) < real (b) : imag(a) < imag(b);
}

double cross(const P &a, const P &b){
    return imag(conj(a)*b);
}

double dot(const P &a, const P &b){
    return real(conj(a) * b);
}

int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > 0)   return +1;       // counter clockwise
    if (cross(b, c) < 0)   return -1;       // clockwise
    if (dot(b, c) < 0)     return +2;       // c--a--b on line
    if (norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;                               // b==c || a--c--b on line
}

vector<P> convex_hull(vector<P> ps) {
    int n = ps.size(), k = 0;
    sort(ps.begin(), ps.end(), predication);
    vector<P> ch(2*n);
    for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
        while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
    for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
        while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
    ch.resize(k-1);
    return ch;
}

int main(){
    int n;
    while(cin >> n && n){
        vector<P> vec;
        vector<P> ch;
        double real,imag;
        for(int i=0;i<n;i++){
            cin >> real;
            cin.ignore();
            cin >> imag;
            vec.push_back(complex<double>(real,imag));
        }
        ch = convex_hull(vec);
        cout << n - ch.size() << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <tuple>

using namespace std;

using P = pair<int, int>;
using i64 = int64_t;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;

int main(int argc, char **argv) {
    int a,b,c;
    cin >> a >> b >> c;
    int ans = c-(a-b);

    cout << max(ans, 0) << endl;

    return 0;
}

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

int main(){
  int A;
  float B;
  cin >> A;
  cin >> B;

  if( B== 1){
    cout << 0 << endl;
  }
  else{
    int s;
  	s = ((B-1)+(A-2))/(A-1);
  	cout << s << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int D;
int C[26];
int S[365][26];
int T[365];

int last[26];

int calc() {
    int cur = 0;
    REP (c, 26) last[c] = -1;

    REP (i, D) {
	int t = T[i];
	last[t] = i;

	cur += S[i][t];
	REP (c, 26) cur -= C[c] * (i - last[c]);

	printf("%d\n", cur);
    }
    return cur;
}

void MAIN() {
    scanf("%d", &D);
    REP (c, 26) scanf("%d", C+c);
    REP (i, D) REP (c, 26) scanf("%d", S[i]+c);
    REP (i, D) scanf("%d", T+i), T[i]--;

    calc();
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
 
namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
			string line;
			int count=0;
			int c,d,e,f;
			c=d=e=f=0;
			while((line=Console.ReadLine())!=null)
			{
				string a = line;
				count++;
				if(count<10&&a[2]=='O')
				c++;
				if(count<10&&a[2]=='B')
				d++;
				if(count<10&&a[2]=='A'&&a.Length==3)
				e++;
				if(count<10&&a[2]=='A'&&a.Length==4)
				f++;
				if(count>9&&a[3]=='O')
				c++;
				if(count>9&&a[3]=='B')
				d++;
				if(count>9&&a[3]=='A'&&a.Length==4)
				e++;
				if(count>9&&a[3]=='A'&&a.Length==5)
				f++;
			}
			Console.WriteLine(e);
			Console.WriteLine(d);
			Console.WriteLine(f);
			Console.WriteLine(c);
}}
}

Measured memory_bytes: 8856
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		DecimalFormat df = new DecimalFormat("####################.####################");

		String a = scan.next();
		String b = scan.next();

		int result1 = Integer.parseInt(a) / Integer.parseInt(b);
		int result2 = Integer.parseInt(a) % Integer.parseInt(b);
		double result3 = Double.parseDouble(a) / Double.parseDouble(b);

		System.out.println(result1 + " " + result2 + " " + df.format(result3));

		scan.close();

	}
}

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

#define M 100000
int dp[M + 1];
int main() {
	int n;
	cin >> n;

	vector<int> num;
	num.push_back(1);
	for (int i = 1;pow(6, i) <= M;i++) {
		num.push_back((int)pow(6, i));
	}
	for (int i = 1;pow(9, i) <= M;i++) {
		num.push_back((int)pow(9, i));
	}

	dp[0] = 0;
	for (int i = 1;i <= M;i++) {
		dp[i] = M;
	}
	for (int i = 0;i < num.size();i++) {
		for (int j = num[i]; j <= M;j++) {
			dp[j] = min(dp[j], dp[j - num[i]] + 1);
		}
	}
	
	cout << dp[n] << endl;


	return 0;
}

Measured memory_bytes: 640
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


n = int(input())
w = list(map(int, input().split()))
# print(w)
sum = 0
for i in range(n):
    sum += w[i]
# print(sum)
mini = sum
prefixsum = 0
for i in range(n):
    prefixsum += w[i]
    mini = min(mini, abs(prefixsum-(sum-prefixsum)))
print(mini)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
	int n,ama,bma;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> a >> b;
		if(a > ama){
			ama = a;
			bma = b;
		}
	}
	cout << ama + bma << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        String s = scanner.next();
        boolean good = true;
        for (int i = 0; i < s.length() - 1; ++i) {
            if (s.charAt(i) == s.charAt(i + 1)) {
                good = false;
                break;
            }
        }
        writer.println(good ? "Good" : "Bad");

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

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

Measured memory_bytes: 21076
#include<bits/stdc++.h>
//author::@whohet-->Het Patel
using namespace std;
int main()
{
	long double l;
	cin>>l;
	std::cout << std::setprecision(9) << std::showpoint;
 // std::cout << d << std::endl;
	cout<<pow(l/3,3);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int N,tmp;

int calc(int base[],int next[]){
	int count = 0;

	 for(int match_point = 0; match_point <= N-1; match_point++){
		 if(base[match_point] != next[match_point]){
			for(tmp = match_point+1; tmp <= N; tmp++){
				if(base[tmp] == next[match_point])break;
			}
			for(int i = tmp; i >= match_point+1; i--){
				swap(base[i],base[i-1]);
				count++;
			}
		 }
	 }

	 return count;
}

 int main(){

	 int M,num[2] = {0,0},index_next = 0;
	 scanf("%d %d",&N,&M);

	 int* base = new int[N];
	 int* next = new int[N];

	 for(int i = 0; i < N; i++){
		 scanf("%d",&base[i]);
		 num[base[i]]++;
	 }

	 if(num[0] == num[1]){
		 int* next2 = new int[N];
		 int* base2 = new int[N];

		 for(int i = 0; i < N; i++)base2[i] = base[i];

		 int index_next2 = 0;

		 for(int i = 0; i < M; i++){
			 scanf("%d",&tmp);

			  for(int k = 0; k < tmp; k++){
				 next[index_next++] = 1 - (i%2);
				 next2[index_next2++] = (i%2);
			 }
		 }

		 printf("%d\n",min(calc(base,next),calc(base2,next2)));

	 }else{
		 int* work = new int[M];
		 int gu_num = 0;

		 for(int i = 0; i < M; i++){
			 scanf("%d",&work[i]);
			 if(i%2 == 0)gu_num += work[i];
		 }


		 for(int i = 0; i < M; i++){
			 for(int k = 0; k < work[i]; k++){
				 if(gu_num == num[0]){
					 next[index_next++] = i%2;
				 }else{
					 next[index_next++] = 1-(i%2);
				 }
			 }
		 }

		 printf("%d\n",calc(base,next));
	 }

	return 0;
}

Measured memory_bytes: 2740
//INCLUDE
//------------------------------------------
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------
 
int main(void){
  ll N;string S;cin>>N>>S;
  bool flag[1000];REP(i,1000)flag[i]=false;
  ll count=0;ll p=0;
  ll IN,JN,KN;
  bool in[10],jn[10],kn[10];REP(i,10)in[i]=jn[i]=kn[i]=false;
  REP(i,N-2){IN=S[i]-'0';
      if(!in[IN]){in[IN]=true;
    	FOR(j,i+1,N-1){JN=S[j]-'0';
          if(!jn[JN]){jn[JN]=true;
     	 	FOR(k,j+1,N){KN=S[k]-'0';
              if(!kn[KN]){kn[KN]=true;
    			p=IN*100+JN*10+KN;
    			flag[p]=true;
              }
            }REP(i,10)kn[i]=false;
          }
        }REP(i,10)jn[i]=false;
      }
  }
  REP(i,1000){
    if(flag[i])count++;
  }cout<<count;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
k=10**5+1
C=[0]*k
for i in range(N):
    C[A[i]]+=1
s=0
for i in range(k):
    s+=i*C[i]
#print(s)
Q=int(input())
for i in range(Q):
    b,c=map(int,input().split())
    s+=(c-b)*C[b]
    C[c]+=C[b]
    C[b]=0
    print(s)


Measured memory_bytes: 20848
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

int main(){
	string S, T, U;
	int A, B;
	cin >> S >> T;
	cin >> A >> B;
	cin >> U;

	if (S == U) {
		A--;
	} else {
		B--;
	}

	cout << A << " " << B << 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 rep1(i, n) for (int i = (int)(n)-1; i >=0; i--)

using ll = long long;

int main(){
  string s;
  ll k;
  cin >> s >> k;
  int l = s.size();
  int one = 0;
  rep(i,l){
    if(s.at(i)=='1')one++;
    else break;
  }
  if(one>=k)cout<<1<<endl;
  else cout<<s.at(one)<<endl;
  return 0;
}


Measured memory_bytes: 256