akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static IEnumerable<string> GetTexts() { return Console.ReadLine().Split(' '); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); }
}

namespace AtCoderBeginnerContest
{
    internal class Program
    {
        public static string C { get; private set; }

        private static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.WriteLine(r); }

        private static object GetResult()
        {
            C = CR.Get();
            switch (C)
            {
                case "a": return "b";
                case "b": return "c";
                case "c": return "d";
                case "d": return "e";
                case "e": return "f";
                case "f": return "g";
                case "g": return "h";
                case "h": return "i";
                case "i": return "j";
                case "j": return "k";
                case "k": return "l";
                case "l": return "m";
                case "m": return "n";
                case "n": return "o";
                case "o": return "p";
                case "p": return "q";
                case "q": return "r";
                case "r": return "s";
                case "s": return "t";
                case "t": return "u";
                case "u": return "v";
                case "v": return "w";
                case "w": return "x";
                case "x": return "y";
                case "y": return "z";
            }
            return null;
        }
    }
}


Measured memory_bytes: 13152
import math

N = int(input())
ans = [0 for _ in range(10050)]

# for i in range(1,N+1):
for x in range(1,math.ceil(math.sqrt(N))):
  for y in range(1,math.ceil(math.sqrt(N))):
    for z in range(1,math.ceil(math.sqrt(N))):
      v = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if v < 10050:
        ans[v] += 1

for i in range(N):
  print(ans[i+1])


Measured memory_bytes: 69656
from datetime import datetime

S = input()
a = S[:2]
b = S[2:]

def is_month(m):
    m = int(m)
    return 0 < m < 13

def is_year(y):
    y = int(y)
    return True

if is_month(a) and is_year(a) and is_month(b) and is_year(b):
    print("AMBIGUOUS")
elif is_month(a) and is_year(b):
    print("MMYY")
elif is_year(a) and is_month(b):
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3312
#include <bits/stdc++.h>
using namespace std;
const int maxn=2*1e5+5;
vector<int> e[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n-1;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        e[a].push_back(b);
        e[b].push_back(a);
    }
    queue<int> q;
    int a[maxn],b[maxn];
    memset(a,-1,sizeof(a));
    memset(b,-1,sizeof(b));
    q.push(1);a[1]=0;b[n]=0;
    while(!q.empty())
    {
        int u=q.front();q.pop();
        for(int i=0;i<e[u].size();i++)
        {
            int v=e[u][i];
            if(a[v]==-1)
            {
                a[v]=a[u]+1;
                q.push(v);
            }
        }
    }
    q.push(n);
    while(!q.empty())
    {
        int u=q.front();q.pop();
        for(int i=0;i<e[u].size();i++)
        {
            int v=e[u][i];
            if(b[v]==-1)
            {
                b[v]=b[u]+1;
                q.push(v);
            }
        }
    }
    int ans1=0,ans2=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]<=b[i]) ans1++;
        else ans2++;
        //cout<<i<<' '<<a[i]<<' '<<b[i]<<endl;
    }
    //cout<<ans1<<' '<<ans2<<endl;
    if(ans1>ans2)cout<<"Fennec"<<endl;
    else cout<<"Snuke"<<endl;
    return 0;
}


Measured memory_bytes: 9728
from copy import copy, deepcopy # pythonのみ．1次元はcopy．多次元はdeepcopy
# from functools import reduce
# from heapq import heapify, heappop, heappush
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import statistics # Pythonのみ
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    def main():

        def next_permutation(a):
            """Generate the lexicographically next permutation inplace.

            https://en.wikipedia.org/wiki/Permutation#Generation_in_lexicographic_order
            Return false if there is no next permutation.
            """
            # Find the largest index i such that a[i] < a[i + 1]. If no such
            # index exists, the permutation is the last permutation
            for i in reversed(range(len(a) - 1)):
                if a[i] < a[i + 1]:
                    break  # found
            else:  # no break: not found
                return False  # no next permutation

            # Find the largest index j greater than i such that a[i] < a[j]
            j = next(j for j in reversed(range(i + 1, len(a))) if a[i] < a[j])

            # Swap the value of a[i] with that of a[j]
            a[i], a[j] = a[j], a[i]

            # Reverse sequence from a[i + 1] up to and including the final element a[n]
            a[i + 1:] = reversed(a[i + 1:])
            return True

        alpha = list(chr(ord('a')+i) for i in range(26))

        S = input()
        if len(S) < 26:
            for i in range(len(S)):
                alpha.remove(S[i])
            return S+alpha[0]
        else:
            S = list(S)
            P = S.copy()
            next_permutation(P)
            for i in range(26):
                if P[i] != S[i]:
                    return ''.join(P[:i+1])
            return -1
    print(main())

resolve()

Measured memory_bytes: 3416
from collections import deque
INF = 1e9
dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]


def bfs(sy,sx):
  if wall[sy][sx] == "#":
    return 0
  que = deque()
  que.append((sy,sx))
  d[sy][sx] = 0
  m = 0
  
  while len(que) > 0:
    y, x = que.popleft()
    
    for i in range(4):
      ny = y+dy[i]
      nx = x+dx[i]
      if 0 <= ny and ny < h and 0 <= nx and nx < w and wall[ny][nx] != "#" and d[ny][nx] == INF:
        que.append((ny,nx))
        d[ny][nx] = d[y][x]+1
        m = max(d[ny][nx],m)
  return m
     
    
h, w = map(int, input().split())
wall = [list(input()) for _ in range(h)]

ans = 0
for i in range(h):
  for j in range(w):
    d = [[INF]*w for _ in range(h)]
    a = bfs(i,j)
    ans = max(ans,a)
print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>

using namespace std;

int main() {
    int n, s;
    double a, m;
    while (true) {
        cin >> n;
        double a = 0, m = 0;
        int N[1001];
        if (n == 0) break;
        for (int i = 0; i < n; i++){
            cin >> s;
            m += s;
            N[i] = s;
        }
        m /= (double)n;
        for (int j = 0; j < n; j++) {
            a += (N[j]-m)*(N[j]-m);
        }
        cout << fixed << std::setprecision(5) << sqrt(a/n) << endl;;
    }
    return 0;
}



Measured memory_bytes: 3272
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
using namespace std;

void file()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

typedef long long ll;
typedef pair<int, int> pi;
const ll INF64 = 1e18;
const int INF = 1e9 + 7;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define x first
#define y second
#define pb push_back
#define all(a) (a).begin(), (a).end()

const int N = 1e5 + 10;
int dp[N];


int main()

{
	file();

	int n;
	cin >> n;
	vector<int> h(n);
	forn(i, n)
		cin >> h[i];
	fore(i, 1, N)
		dp[i] = INF;
	dp[1] = abs(h[0] - h[1]);
	fore(i, 2, n)
	{
		int c1 = abs(h[i] - h[i - 2]);
		int c2 = abs(h[i] - h[i - 1]);
		dp[i] = min(dp[i - 2] + c1, dp[i - 1] + c2);
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using Debug;
//using static System.Globalization.CultureInfo;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var nab = Input.ar;
        var str = ReadLine();
        var ct = 0;var ct2 = 0;
        for (var i = 0; i < nab[0]; i++)
            if (str[i] == 'c' || ct >= nab[1] + nab[2])
                WriteLine("No");
            else if (str[i] == 'a') { WriteLine("Yes"); ct++; }
            else if (ct2 < nab[2]) { WriteLine("Yes"); ct++;ct2++; }
            else WriteLine("No");

    }
}

public class Input
{
    public static string read => ReadLine().Trim();
    public static int[] ar => read.Split(' ').Select(int.Parse).ToArray();
    public  static int num => ToInt32(read);
    public static long[] arL => read.Split(' ').Select(long.Parse).ToArray();
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(_ => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(_ => arL).ToArray();
    public static T getValue<T>(string g)
    {
        var t = typeof(T);
        if (t == typeof(int))
            return (T)(object)int.Parse(g);
        if (t == typeof(long))
            return (T)(object)long.Parse(g);
        if (t == typeof(string))
            return (T)(object)g;
        if (t == typeof(char))
            return (T)(object)char.Parse(g);
        if (t == typeof(double))
            return (T)(object)double.Parse(g);
        if (t == typeof(bool))
            return (T)(object)bool.Parse(g);
        return default(T);
    }
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

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

int main(){
  int n,i,j,C[10001];
  int *A,*B;
  scanf("%d",&n);
  A = malloc(sizeof(int)*n+1);
  B = malloc(sizeof(int)*n+1);

  for(i=0 ; i<=10000 ; i++){C[i]=0;}
  for(i=1 ; i<=n ; i++){
    scanf("%d",&A[i]);
    C[A[i]]++;
  }
  for(i=1;i<=10000;i++){C[i]+=C[i-1];}
  for (j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<n;i++){printf("%d ",B[i]);}
  printf("%d\n",B[n]);

  return 0;
}


Measured memory_bytes: 17464
n = int(input())

def dfs(s, mx):
    if len(s) == n:
        print(s)
    else:
        m = ord(mx) - ord("a")
        for i in range(m+1):
            c = chr(i + ord("a"))
            if c == mx:
                dfs(s + c, chr(ord(mx)+1))
            else:
                dfs(s + c, mx)

dfs("", "a")


Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
#define ll 			long long int
#define vll 		vector<long long int>
#define vi  		vector<int>
#define vpi 		vector<pair<int,int>>
#define PR 		fixed<<setprecision(10)
#define set(x)		__builtin_popcount(x)
#define ffs(x) 		__builtin_ffs(x)
#define clz(x) 		__builtin_clz(x)
#define all(v) 		v.begin(),v.end()
#define PI 3.14159265358979323846264
const ll maxn=1e5+5;
vector<int> graph[maxn];
vector<int> vis(maxn,0);
vector<int> dis(maxn,INT_MAX);
vector<int> par(maxn);
int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a,b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    queue<int> q;
    q.push(1);
    dis[1]=0;
    vis[1]=1;
    while(!q.empty()){
        int k = q.front();
        q.pop();
        for(int c:graph[k]){
            if(!vis[c]){
                vis[c]=1;
                // cout << c <<'\n';
                q.push(c);
                dis[c]=dis[k]+1;
                par[c]=k;
            }
        }
    }
    bool ok = 1;
    for(int i=1;i<=n;i++)if(dis[i]==INT_MAX)ok=0;
    if(ok){
        cout << "Yes\n";
        for(int i=2;i<=n;i++)cout << par[i]<<'\n';
    }
    else{
        cout << "No";}
}



Measured memory_bytes: 11108
#include <iostream>
using namespace std;
int sumdigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main() {
  int n;
  cin >> n;
  int sum = sumdigits(n);
  if (n % sum == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())

W = []
for i in range(N):
    if i == 0:
        x = input()
        W.append(x)
    else:
        x = input()
        if x in W:
            print("No")
            exit()
        elif W[i-1][-1] != x[0]:
            print("No")
            exit()
        else:
            W.append(x)

print("Yes")

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007; //998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_pow(int base, int exp)
{
	_T ans = 1;

	for (int i = 0; i < exp; i++) {
		ans *= (_T)base;
	}
	return ans;
}

static void D();

int main()
{
	D();
	fflush(stdout);
	return 0;
}

static void D()
{
	int N, M;
	get(N, M);

	std::vector<int> num(N, -1);

	for (int i = 0; i < M; i++) {
		int s, c;
		get(s, c);

		if ((s > N) || ((num[s - 1] != -1) && (num[s - 1] != c))) {
			printf("-1\n");
			return;
		}
		num[s - 1] = c;
	}

	if (num[0] == 0 && N > 1) {
		printf("-1\n");
		return;
	}
	else if (num[0] == -1 && N > 1) num[0] = 1;

	for (int i = 0; i < N; i++) {
		if (num[i] < 0) num[i] = 0;
		printf("%d", num[i]);
	}
	putchar('\n');
}



Measured memory_bytes: 3704
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
n t
c1 t1
...
cn tn
 */
int n,t;

int main(){
  cin>>n>>t;
  int minc = 1001;
  REP(i,n){
    int c,ti;
    cin>>c>>ti;
    if(ti<=t)
      minc = min(minc, c);
  }

  if(minc > 1000)
    cout << "TLE\n";
  else
    cout << minc << endl;
  return 0;
}


Measured memory_bytes: 256
import qualified Data.Map as M
import Data.List

data ABC = AB | BC | AC deriving Read

main = do
  li <- getLine
  let [n,a,b,c] = map read $ words li
  co <- getContents
  let ss = map read $ lines co
  let ans = compute n a b c ss
  putStrLn ans

compute :: Int -> Int -> Int -> Int -> [ABC] -> String
compute n a b c ss =
  case M.lookupMin $ foldl step (M.singleton (a,b,c) "") ss of
    Nothing -> "No"
    Just (_,ts) -> "Yes\n" ++ intersperse '\n' (reverse ts)

step m abc = M.fromList [ e1 | e0 <- M.assocs m, e1@((a,b,c),_) <- f abc e0, a >= 0, b >= 0, c >= 0]

-- Lensを使えばこのクローンはきれいにできそうだが。
f AB ((a,b,c),st) = [((succ a, pred b, c),'A':st) | a <= b] ++ [((pred a, succ b, c),'B':st) | a >= b]
f AC ((a,b,c),st) = [((succ a, b, pred c),'A':st) | a <= c] ++ [((pred a, b, succ c),'C':st) | a >= c]
f BC ((a,b,c),st) = [((a, succ b, pred c),'B':st) | b <= c] ++ [((a, pred b, succ c),'C':st) | b >= c]


Measured memory_bytes: 13060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int a, b;
  cin >> a >> b;
  int sum = 0;
  for (int i = 1; i <= b-a; i++) {
    sum += i;
  }
  dump(sum-b);
  return 0;
}


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

public class Main {

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

        int n = nextInt(), k = nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = nextInt();

        boolean[] winningPositions = new boolean[k + 1];

        winningPositions[0] = true;
        for (int value : a) winningPositions[value] = true;

        for (int i = 1; i < winningPositions.length; i++) {
            for (int value: a) {
                if (value < i) winningPositions[i] |= !winningPositions[i - value];
            }
        }

        System.out.println(winningPositions[k] ? "First" : "Second");
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

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

Measured memory_bytes: 23252
#include <iostream>
#include <vector>

using namespace std;

int scene[100][100], picture[50][50], temporary[50][50];

int main(){
	while(true){
		int n, m;
		cin >> n >> m;
		if(n == 0 && m == 0){ break; }
		for(int y = 0; y < n; ++y){
			for(int x = 0; x < n; ++x){ cin >> scene[y][x]; }
		}
		for(int y = 0; y < m; ++y){
			for(int x = 0; x < m; ++x){ cin >> picture[y][x]; }
		}
		bool found = false;
		int answerx = n, answery = n;
		for(int r = 0; r < 4; ++r){
			for(int y = n - m; y >= 0; --y){
				for(int x = n - m; x >= 0; --x){
					bool flag = true;
					int tx, ty;
					for(int py = m - 1; py >= 0 && flag; --py){
						for(int px = m - 1; px >= 0; --px){
							if(picture[py][px] >= 0){
								if(picture[py][px] != scene[y + py][x + px]){
									flag = false;
									break;
								}else{
									tx = x + px;
									ty = y + py;
								}
							}
						}
					}
					if(flag){
						found = true;
						if(ty < answery){
							answery = ty;
							answerx = tx;
						}else if(ty == answery){
							answerx = min(answerx, tx);
						}
					}
				}
			}
			for(int y = 0; y < m; ++y){
				for(int x = 0; x < m; ++x){ temporary[y][x] = picture[x][m - y - 1]; }
			}
			for(int y = 0; y < m; ++y){
				for(int x = 0; x < m; ++x){ picture[y][x] = temporary[y][x]; }
			}
		}
		if(found){
			cout << (answerx + 1) << " " << (answery + 1) << endl;
		}else{
			cout << "NA" << endl;
		}
	}
	return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

pair<ll, ll> f(vector<ll> &A, vector<ll> &B){
    ll sum_a = 0;
    for(ll a : A){
        sum_a += a;
    }

    ll sum_b = 0;
    for(ll b : B){
        sum_b += b;
    }
    
    ll diff = sum_a - sum_b;
    for(ll a : A){
        // aを差し出す
        ll c = (sum_b - sum_a + 2*a);
        if(c%2!=0) continue;
        ll b = c / 2;
        auto it = lower_bound(ALL(B), b);
        if(it==B.end()){
            continue;
        }else{
            if(*it==b){
                return make_pair(a, b);
            }
        }
    }
    return make_pair(-1, -1);
}

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

    // input
    for(;;){
        ll N, M;
        cin >> N >> M;

        if(N==0 && M==0){
            return 0;
        }

        vector<ll> A(N);
        FOR(i, 0, N){
            cin >> A[i];
        }
        sort(ALL(A));

        vector<ll> B(M);
        FOR(i, 0, M){
            cin >> B[i];
        }
        sort(ALL(B));

        auto p = f(A, B);

        if(p.first==-1){
            p(-1);
        }else{
            p2(p.first, p.second);
        }
    }
    
    return 0;
}


Measured memory_bytes: 3080
#include <stdio.h>
int main(){

  int M, N, L, bank=0, i, flag=0, moth;
  while(1){
    L = 0;
    bank = 0;    
    flag = 0;
    moth = 0;
    scanf("%d", &L);
    if(L == 0) break;
    for(i = 1; i <= 12; i++){
      scanf("%d %d", &M, &N);
      bank = bank + (M - N);
      if(bank >= L && flag == 0){
	flag = 1;
	moth = i;
      }
    }

    if ( flag == 1){
      printf("%d\n", moth);
    }else{
      printf("NA\n");
    }
  }
  return 0;
}

Measured memory_bytes: 612
import java.time.LocalDate;
import java.time.temporal.TemporalAdjusters;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int M1;
    int D1;
    int M2;
    int D2;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.M1 = sc.nextInt();
        this.D1 = sc.nextInt();
        this.M2 = sc.nextInt();
        this.D2 = sc.nextInt();
    }
    
    //解答処理
    private boolean solve() {
        boolean judge = false;
        
        LocalDate date = LocalDate.of(2019, M1, D1);
        //LocalDate date2 = LocalDate.of(2019, M2, D2);
        LocalDate date3 = date.with(TemporalAdjusters.lastDayOfMonth());
        
        if (date == date3) {
        	judge = true;
        }
        
        return judge;
    }
    
    //出力
    public void show(boolean answer) {
        if (answer) {
        	System.out.println(1);
        } else {
        	System.out.println(0);
        }
    }

}


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

using namespace std;

const int N = 101;
int n, k;
int a[N];

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

    cin >> n >> k;
    for(int i = 0; i < k; i++)
    {
        int d;
        cin >> d;
        for(int j = 0; j < d; j++)
        {
            int c;
            cin >> c;
            a[c]++;
        }
    }

    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        if(!a[i])
            ans++;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int a[18];
int x[18][18];
int y[18][18];

int solve() {
  int ans = 0;
  FOR(i, 1, 1 << n) {
    bool ok = true;
    int count = 0;
    FOR(j, 1, n + 1) {
      if(!(i & (1 << (j - 1)))) continue;
      count++;
      FOR(k, 1, a[j] + 1) {
        if(((i >> (x[j][k] - 1)) & 1) ^ y[j][k]) ok = false;
      }
    }
    if(ok) ans = max(ans, count);
  }

  return ans;
}

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

  cin >> n;

  FOR(i, 1, n + 1) {
    cin >> a[i];
    FOR(j, 1, a[i] + 1) {
      cin >> x[i][j] >> y[i][j];
    }
  }

  cout << solve() << endl;
}


Measured memory_bytes: 256
# coding: utf-8
import fractions
#N = int(input())

h, w = map(int,input().split())
h_list = []
w_list = []
F = []
for i in range(h):
    l = list(input())
    F.append(l)
    if list(set(l)) == ['.']:
        w_list.append(i)
        
for i in range(w):
    cnt = 0
    for j in range(h):
        if F[j][i] == '.':
            cnt += 1
        else:
            break
    if cnt == h:
        h_list.append(i)
A = []
#print(h_list,w_list)#ここまでOK
for i in range(h):
    if i not in w_list:
        l = []
        for j in range(w):
            if j not in h_list:
                #print(F[i][j])
                l.append(F[i][j])
        
        A.append(l)

for i in range(len(A)):
    print(''.join(A[i]))

Measured memory_bytes: 5216
#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++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    bool flag=false;
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            if(i*j==n) {
                flag=true;
            }
        }
    }
    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3624
<?php
fscanf(STDIN, "%d %d %d", $H, $W, $K);
for ($i = 0; $i < $H; $i++) {
    $table[$i] = trim(fgets(STDIN));
}

$x = pow(2, $H);
$y = pow(2, $W);
$count = 0;

for ($i = 0; $i < $x; $i++) {
    $i_str = str_pad(decbin($i), $H, 0, STR_PAD_LEFT);
    for ($j = 0; $j < $y; $j++) {
        $black = 0;
        $j_str = str_pad(decbin($j), $W, 0, STR_PAD_LEFT);
        for ($k = 0; $k < $H; $k++) {
            for ($l = 0; $l < $W; $l++) {
                if ($table[$k][$l] !== '#') continue;
                if ($i_str[$k] === '1' or $j_str[$l] === '1') continue;
                $black++;
            }
        }
        if ($black === $K) {
            $count++;
        }
    }
}

echo $count, PHP_EOL;

Measured memory_bytes: 16292
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 5050
int K,n;
struct A {
	char s[10];
	bool operator < (const A &x) const {
		return strcmp(s,x.s)<0;
	}
	bool operator == (const A &x) const {
		return strcmp(s,x.s)==0;
	}
}a[N<<3];
char s[N];
int main() {
	int cnt=0;
	scanf("%s%d",s,&K);
	int i,j,k;n=strlen(s);
	for(i=0;i<n;i++) {
		for(j=1;j<=5&&i+j-1<n;j++) {
			++cnt;
			for(k=i;k<=i+j-1;k++) a[cnt].s[k-i]=s[k];
		}
	}
	sort(a+1,a+cnt+1);
	cnt=unique(a+1,a+cnt+1)-a-1;
	printf("%s\n",a[K].s);
}


Measured memory_bytes: 384
A, B, C = map(int, input().split())


def func(x):
    cnt = 0
    while x % 2 == 0:
        x //= 2
        cnt += 1

    return cnt


if A % 2 or B % 2 or C % 2:
    print(0)
elif A == B == C:
    print(-1)
else:
    m = min(func(A + B), func(B + C), func(C + A))
    print(m)


Measured memory_bytes: 3060
#include <utility>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <climits>
#include <cmath>
#include <limits.h>
#include <ios>
#include <iomanip>
#define REP(i,n) for(int i=0;i<n;i++)
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
ll gcd(ll a, ll b){return b? gcd(b, a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main() {
	cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S; 
  int N = S.size();
  int ans = 0;
  if(N<2){
    ans = 0;
  } else{
    int zeros= 0;
    int ones = 0;
    for(int i =0; i < N; i++){
      if(S[i] == '0'){
        zeros++;
      }else{
        ones++;
      }
    }
    if(zeros>ones){
      ans = ones *2;
    }else{
      ans = zeros * 2;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 512
import java.util.*;

public class Main{
    public static void main(String[] args) {    
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int l = Integer.parseInt(sc.next());
        int data[] = new int[n];
        int sum = 0;
        int min = Integer.MAX_VALUE;
        boolean minFlag = true;
        for(int i = 0;i<n;i++){
            data[i] = l + i;
            sum += data[i];
            if(data[i] < 0){
                data[i] *= -1;
                minFlag = false;
            }else{
                minFlag = true;
            }
            min = Math.min(min,data[i]);
        }
        if(minFlag == false){
            min *= -1;
        }
        System.out.println(sum - min);
    }
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int N;
    cin >> N;
    vector<char> S(N);
    rep(i, N) cin >> S.at(i);

    int cnt = 0;
    rep(i, N) {
        if(S.at(i) == 'A' && i < N - 2)
            if(S.at(i + 1) == 'B')
                if(S.at(i + 2) == 'C') cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define LiangJiaJun main
using namespace std;
int n,h[100004];
int f[100004];
int w33ha(){
    for(int i=1;i<=n;i++)scanf("%d",&h[i]);
    f[1]=0;
    f[2]=abs(h[2]-h[1]);

    for(int i=3;i<=n;i++){
        f[i]=min(f[i-1]+abs(h[i]-h[i-1]),f[i-2]+abs(h[i]-h[i-2]));
    }
    printf("%d\n",f[n]);
    return 0;
}
int LiangJiaJun(){
    while(scanf("%d",&n)!=EOF)w33ha();
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;

public class Main {
	public static void main(String[] args) {
		FastReader r = new FastReader();
		String s = r.str();
		String t = r.str();
		for(int i = 0; i < s.length(); i++) {
			String temp = s.substring(i, s.length()) + s.substring(0,i);
			if(temp.equals(t)) {
				print("Yes");
				return;
			}
		}
		print("No");
	}
	
	public static int getDigitSum(int n) {
		String str = ""+n;
		int sum = 0;
		for(int i = 0; i<str.length();i++) {
			sum += Integer.parseInt(""+str.charAt(i));
		}
		return sum;
	}

	public static void rolling(int[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}
	
	public static void rolling(long[] arr) {
		if (arr.length < 2)
			return;
		for (int i = 1; i < arr.length; i++)
			arr[i] += arr[i - 1];
	}

	public static void reverse(int[] arr) {
		for (int i = 0; i < arr.length / 2; i++) {
			int temp = arr[i];
			arr[i] = arr[arr.length - 1 - i];
			arr[arr.length - 1 - i] = temp;
		}
	}
	
	public static void swap(int[] arr, int pos1, int pos2) {
		int temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	public static void swap(long[] arr, int pos1, int pos2) {
		long temp = arr[pos1];
		arr[pos1] = arr[pos2];
		arr[pos2] = temp;
	}
	
	public static String al(String s) {
		return s + "\n";
	}

	public static void print(String s) {
		System.out.println(s);
	}

	public static void print(long s) {
		System.out.println(s);
	}

	public static void print(int s) {
		System.out.println(s);
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		int ri() {
			return Integer.parseInt(str());
		}

		long rl() {
			return Long.parseLong(str());
		}

		double rd() {
			return Double.parseDouble(str());
		}

		String str() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

		String[] rsa() {
			return str().split(" ");
		}

		int[] ria() {
			String[] s = rsa();
			int[] arr = new int[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(s[i]);
			return arr;
		}

		long[] rla() {
			String[] s = rsa();
			long[] arr = new long[s.length];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(s[i]);
			return arr;
		}

		char[] rca() {
			String s = str();
			char[] arr = new char[s.length()];
			for (int i = 0; i < arr.length; i++)
				arr[i] = s.charAt(i);
			return arr;
		}
		
		String[] rsaml(int m) {
			String[] arr = new String[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = str();
			return arr;
		}

		int[] riaml(int m) {
			int[] arr = new int[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Integer.parseInt(str());
			return arr;
		}

		long[] rlaml(int m) {
			long[] arr = new long[m];
			for (int i = 0; i < arr.length; i++)
				arr[i] = Long.parseLong(str());
			return arr;
		}
	}
}

class Node {
	public int val;
	public boolean visited;
	public Node(int v) { val=v; }
}


Measured memory_bytes: 23124
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N, K = lr()
X = lr()
answer = []
for i in range(N-K+1):
    l = X[i]; r = X[i+K-1]
    a = abs(l) + abs(r-l)
    b = abs(r) + abs(l-r)
    answer.append(min(a, b))

print(min(answer))
# 03

Measured memory_bytes: 14480
from collections import defaultdict
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def root(par, x):
    if par[x] == x:
        return x
    else:
        return root(par, par[x])


def unite(rank, par, x, y):
    x = root(par, x)
    y = root(par, y)

    if x == y:
        return

    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1


def main():
    N, K, L = map(int, readline().split())
    m = map(int, read().split())
    pq = list(zip(m, m))
    pq, rs = pq[:K], pq[K:]

    par = list(range(N))
    rank = [0] * N
    for p, q in pq:
        p -= 1
        q -= 1
        unite(rank, par, p, q)

    par_t = list(range(N))
    rank_t = [0] * N
    for r, s in rs:
        r -= 1
        s -= 1
        unite(rank_t, par_t, r, s)

    pp = [(0, 0)]*N
    dd = defaultdict(list)
    for i in range(N):
        par[i] = root(par, i)
        par_t[i] = root(par_t, i)
        pp[i] = (par[i], par_t[i])
        dd[pp[i]].append(i)

    cnt = [0] * N
    for i in range(N):
        cnt[i] = len(dd[pp[i]])

    print(*cnt)


main()


Measured memory_bytes: 128680
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
#include <chrono>

#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e6 + 20;
#endif

//tg: @galebickosikasa
 
const ll inf = (ll) 2e9;
const ld pi = asin (1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

ll mult (ll a, ll b) {
	return a * b % mod;
}

ll add (ll a, ll b) {
	int c = a + b;
	if (c >= mod) c -= mod;
	return c;
}

ll powmod (ll a, ll n) {
	if (n == 0) return 1;
	if (n % 2) return mult (a, powmod (a, n - 1));
	ll b = powmod (a, n / 2);
	return mult (b, b);
}

ll inv (int a) {
	return powmod (a, mod - 2);
}

int f[maxn], rev[maxn];

int C (int n, int k) {
	return mult (f[n], mult (rev[k], rev[n - k]));
}

int S (int i, int j) {
	if (i < 0 || j < 0) return 0;
	return C (i + j + 2, i + 1);
}

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	f[0] = 1;
	fl (i, 1, maxn) {
		f[i] = mult (f[i - 1], i);
		rev[i] = inv (f[i]);
	}
	int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	int ans = S (r2, c2) - S (r1 - 1, c2) - S (r2, c1 - 1) + S (r1 - 1, c1 - 1);
	ans %= mod;
	if (ans < 0) ans += mod;
	cout << ans;









}

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

int main() {
	int n,m;
	cin>>n>>m;
	vector <int> v;
	for(int i=1;i<=sqrt(m);i++)
	  {
	  	  if(i==sqrt(m) && i*1ll*i==m)
	  	    {
	  	    	 v.push_back(i);
	  	    }
	  	  if(m%i==0)
	  	    {
	  	    	 v.push_back(i);
	  	    	 v.push_back(m/i);
	  	    }
	  }
  sort(v.begin(),v.end());
    for(int i=(int)v.size()-1;i>=0;i--)
      {
      	   if(m/v[i]>=n)
      	     {cout<<v[i]<<'\n';
      	       return 0;
      	     }
      }
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from itertools import combinations_with_replacement


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


def slv(N, M, Q, ABCD):
    ans = 0
    for a in combinations_with_replacement(range(1, M+1), r=N):
        t = 0
        for abcd in ABCD:
            A, B, C, D = abcd
            if a[B-1] - a[A-1] == C:
                t += D
        ans = max(ans, t)
    return ans


def main():
    N, M, Q = read_int_n()
    ABCD = [read_int_n() for _ in range(Q)]
    print(slv(N, M, Q, ABCD))


if __name__ == '__main__':
    main()


Measured memory_bytes: 67712
#import sys
N = int(input())
B = list(map(int, input().split()))
#S = [input() for _ in range(H)]
#T = [list(map(int,input().split())) for _ in range(N)]
A = [0] * N
A[0] = B[0]
A[N-1] = B[N-2]
for i in range(N - 2) :
    A[i+1] = min(B[i],B[i+1])
print(sum(A))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=998244353ll;

bool is_valid(int x, int y, int a, int b){
    return x>=a && y>=b;
}

void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<vector<long long>> dp(c+1,vector<long long>(d+1,0ll));
    dp[a][b]=1;
    for(int i=a;i<=c;i++){
        for(int j=b;j<=d;j++){
            if(i!=a || j!=b){
                if(is_valid(i-1,j,a,b)) dp[i][j]+=(dp[i-1][j]*j)%MOD;
                if(is_valid(i,j-1,a,b)) dp[i][j]+=(dp[i][j-1]*i)%MOD;
                if(is_valid(i-1,j-1,a,b)) dp[i][j]+=(dp[i-1][j-1]*(MOD-(1ll*(i-1)*(j-1))%MOD))%MOD;
                dp[i][j]%=MOD;
            }
        }
    }
    cout<<dp[c][d]<<"\n";
}   

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

    solve();
    return 0;
}

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

long long M =  1000000007;

int main() {
    long long N;
    cin >> N;
    if(N==1){
        cout << 0 << endl;
        return 0;
    }
    if(N==2){
        cout << 2 << endl;
        return 0;
    }
    long long cnt1 = 1;
    long long cnt2 = 2;
    long long cnt3 = 1;
    for(long long i=0;i<N;i++){
        cnt1 *= 10;
        cnt1 %= M;
        cnt2 *= 9;
        cnt2 %= M;
        cnt3 *= 8;
        cnt3 %= M;
    }
    long long ans = (cnt1+cnt3-cnt2)%M;
    cout << (ans+M)%M << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
const int max_n = 1e6;
ll a[2][200];
int main(){
  cin >> n;
  vector<ll> x(n+1),y(n+1),t(n+1);
  for(int i=1 ; i<=n ; i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  x[0] = y[0] = t[0] = 0;
  for(int i=0 ; i+1<=n ; i++){
    ll time = t[i+1]-t[i];
    ll d = abs(x[i]-x[i+1])+abs(y[i]-y[i+1]);
    if(time < d){
      cout << "No" << endl;
      return 0;
    }else{
      if((time-d) %2 != 0){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 2560
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

char s[maxn];
int len,suf[maxn],pre[maxn],mn,ans;

int main()
{
	scanf("%s",s+1); len=strlen(s+1); mn=0; ans=inf;
	rep(i,1,len) pre[i]=pre[i-1]+(s[i]=='0'?-1:1),mn=min(mn,pre[i]);
	suf[len]=pre[len]; per(i,len-1,1) suf[i]=min(suf[i+1],pre[i]);
	rep(j,1,2)
	{
		int mx=0,nw=0,p=0;
		rep(i,1,len)
		{
			if(s[i]!='?') nw+=(s[i]=='0'?-1:1);
			else
			{
				if(suf[i]-pre[i-1]+nw-2>=mn) nw--;
				else nw++;
			}
			p=max(p,nw);
		}
		ans=min(ans,p-mn); mn--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
typedef pair<int,int> P;
#define INF 1e9
#define rep(i,N) for(int i=0;i<N;i++)

int main(){
    int w,d;
    while(cin>>w>>d){
        if(w == 0)break;
        int h[w],hd[d];
        rep(i,w)cin>>h[i];
        rep(i,d)cin>>hd[i];
        bool used_h[w],used_hd[d];
        rep(i,w)used_h[i] = false;
        rep(i,d)used_hd[i] = false;
        int ans = 0;
        rep(i,w){
            rep(j,d){
                if(h[i]==hd[j] && !used_h[i] && !used_hd[j]){
                    used_h[i] = true;
                    used_hd[j] = true;
                    break;
                }
            }
        }
        rep(i,w)ans += h[i];
        rep(i,d)if(!used_hd[i])ans += hd[i];
        //rep(i,d)cout<<used_hd[i]<<" ";
        //cout<<endl;
        cout<<ans<<endl;
    }
}


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

int main() {
  string a, b;
  cin >> a >> b;
  bool flag = true;
  if(a.at(0) != b.at(2)) flag = false;
  if(a.at(1) != b.at(1)) flag = false;
  if(a.at(2) != b.at(0)) flag = false;
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;


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


  vector<string> f(h, string(w, '0'));

  if(h/2 < b){
    cout << "No" << endl;
    return 0;
  }
  if(w/2 < a){
    cout << "No" << endl;
    return 0;
  }

  rep(hx, h){
    rep(wx, w){
      if(hx < b && wx < a)   continue;
      if(b <= hx && a <= wx) continue;
      f[hx][wx] = '1';
    }
  }
  
  for(auto s : f) cout << s << endl;



  return 0;
}


Measured memory_bytes: 2304
using System;

class Program {
    static void Main() {
        var n = int.Parse(Console.ReadLine());

        for (var i = 1; i <= n; i++) {
            Console.WriteLine("Case {0}:", i);

            var s = int.Parse(Console.ReadLine());

            for (int j = 0; j < 10; j++) {
                s = s * s / 100 % 10000;
                Console.WriteLine(s);
            }
        }
    }
}

Measured memory_bytes: 8968
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
using namespace std;

int main(){

  int a, b, c;
  cin >> a >> b >> c;

  if(a==b){
    cout << c << endl;
  } else if(b==c){
    cout << a << endl;
  } else if(a == c){
    cout << b << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    long long D;
    cin >> N >> D;
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        long long X, Y;
        cin >> X >> Y;
        if (X * X + Y * Y <= D*D)
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  int a, b,ans=0,tmp;
  cin >> a >> b;
  rep(i,a){
    cin >> tmp;
    ans += min(tmp,b-tmp)*2;
  }
  cout << ans;
}

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

// template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
// template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 998244353
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    string s,t; cin>>s>>t;
    int ss = s.size(), tt = t.size();
    vector<vector<int>> dp(ss+10,vector<int>(tt+10,0));//dp[i][j] = i文字j文字の最長の長さ
    rep(i,ss){
        rep(j,tt){
            if(s[i]==t[j]) dp[i+1][j+1] = max(dp[i][j]+1,dp[i+1][j+1]);
            dp[i+1][j+1] = max({dp[i][j+1],dp[i+1][j],dp[i+1][j+1]});
        }
    }
    int l = dp[ss][tt];
    int is = ss, it = tt;
    string res = "";
    while(is>0&&it>0){
        if(s[is-1]==t[it-1]){
            res  = res + s[is-1];
            is--; it--;
        }else if(dp[is][it] == dp[is][it-1]){
            it--;
        }else is--;
    }
    reverse(res.begin(),res.end());
    cout<<res<<endl;
}

Measured memory_bytes: 39124
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int n,sum=0;
	cin>>n;
	cin>>s;
	for(int i=0;i<n-2;i++)
	{
		string t;
		t=t+s[i]+s[i+1]+s[i+2];
		//cout<<t<<endl;
		if(t=="ABC")
		sum++;
	}
	cout<<sum;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,l;
    cin>>n>>l;
    string a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++)
    {
        cout<<a[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3652
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[N];
		for (int i = 0; i < N; i++) {
			L[i] = sc.nextInt();
		}
		sc.close();
		// 配列のソート
		Arrays.sort(L);

		int ans = 0;
		for (int i = 0; i < N - 2; i++) {
			for (int j = i + 1; j < N - 1; j++) {
				int l = j;
				int r = N;
				while(r - l > 1) {
					int m = (l + r) / 2;
					if (L[i] + L[j] > L[m]) {
						l = m;
					} else {
						r = m;
					}
				}
				ans += l - j;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26180
import java.io.*;

class Main{
    public static void main(String args[]){
          int x;
          String buf;

          BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
          
          try{
          buf=br.readLine();
          x=Integer.parseInt(buf);
          System.out.println(x*x*x);

          }catch(IOException e){
                System.out.println("入出力エラーです");
          }
    }
}




Measured memory_bytes: 24224