akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long

void solve()
{
    string s;
    cin>>s;

    if(s == "Cloudy")
        cout<<"Rainy\n";
    else if(s == "Sunny")
        cout<<"Cloudy\n";
    else
        cout<<"Sunny\n";    
}

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

    //int t;
    //cin>>t;

    //while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256
X = int(input())
MAX = 150
al = []
for i in range(MAX):
    al.append(i**5)
    al.append(-i**5)

for i,A in enumerate(al):
    for j,B in enumerate(al):
        if(A-B==X):
            a = i//2 if i%2==0 else -(i//2)
            b = j//2 if j%2==0 else -(j//2)
            print("{} {}".format(a,b))
            exit(0)
    

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

#define int long long
#define uint unsigned int
#define pii pair<int, int>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin()), ((c).end())

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

int N;
vector<int> G[100010];
int dp1[100010];
int dp2[100010];

void dfs1(int v, int par) {
  for (auto& nv : G[v]) if (nv != par) {
    dfs1(nv, v);
    CHMAX(dp1[v], dp1[nv]+1);
  }
}

void dfs2(int v, int par, int d_par) {
  vector<pii> w;
  w.EMPB(0, -1);
  for (auto& nv : G[v]) {
    w.EMPB((nv == par ? d_par : dp1[nv]) + 1, nv);
  }
  SORT(w); REV(w);
  dp2[v] = w[0].first;
  for (auto& nv : G[v]) if (nv != par) {
    dfs2(nv, v, w[nv == w[0].second].first);
  }
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  REP(i, N-1) {
    int s, t;
    cin >> s >> t;
    s--; t--;
    G[s].PB(t);
    G[t].PB(s);
  }
  dfs1(0, -1);
  dfs2(0, -1, 0);
  REP(i, N) {
    cout << 2*(N-1) - dp2[i] << endl;
  }

  return 0;
}


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


int main() {
 string s,t;
  int a, b;
  string u;
  
  cin >> s >> t >> a >> b >>u;
  
  if(s == u){
  a--;
  }
  if(t == u){
  b--;
  }
  
  cout << a << " " << b << endl;
}


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

using namespace std;

const int N = 1e5 + 3;
int a[N], f[N], n, k;

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
	f[1] = 0;
	for (int i = 2; i <= n; ++i) {
		f[i] = 1e9 + 7;
		for (int j = max(1, i - k); j < i; ++j)
			f[i] = min(f[i], f[j] + abs(a[j] - a[i]));
	}
	printf("%d", f[n]);
	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
using namespace std;
#define MAX_N 100
#define MAX_V 100
const int INF = 1e9 + 7;
int dp[MAX_N + 1][MAX_N * MAX_V + 1];
int N, W;
int ans = 0;
int v[MAX_N] , w[MAX_N];
void DP(){
  for(int i = 0; i <= MAX_N * MAX_V; i++){
    dp[0][i] = INF;
  }
  dp[0][0] = 0;
  for(int i = 0; i < N; i++){
    for(int k = 0; k <= MAX_N * MAX_V; k++){
      if(k < v[i]){
        dp[i + 1][k] = dp[i][k];
      }else{
        dp[i + 1][k] = min(dp[i][k], dp[i][k - v[i]] + w[i]);
      }
    }
  }
  for(int i = 0; i <= MAX_N * MAX_V; i++ ){
    if(dp[N][i] <= W){
      ans = i;
    }
  }
}
int main(){
  cin >> N >> W;
  for(int i = 0; i < N; i++){
    cin >> v[i] >> w[i];
  }
  DP();
  
  //for(int i = 0; i <= MAX_N * MAX_V; i++){
    //if(dp[N][i] <= W) cout << dp[N][i] << endl;
  //}
  printf("%d\n", ans);
  return 0;
}



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

using lli = long long;

int main() {
  int n, k, s;
  cin >> n >> k >> s;
  for (int i = 1; i <= n; ++i) {
    if (i <= k) cout << s;
    else cout << (s == (int)1E9 ? 1 : s + 1);
    cout << " \n"[i == n];
  }
  
  return 0;
}

Measured memory_bytes: 1280
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)
	var shops [2]Shop
	A := 0
	B := 1
	n := getNextInt(scanner)
	shops[A].g = getNextInt(scanner)
	shops[A].s = getNextInt(scanner)
	shops[A].b = getNextInt(scanner)
	shops[B].g = getNextInt(scanner)
	shops[B].s = getNextInt(scanner)
	shops[B].b = getNextInt(scanner)

	dp := make([]int, n+1)
	for i := 1; i <= n; i++ {
		dp[i] = i
		if shops[A].g <= i {
			dp[i] = maxint(dp[i], dp[i-shops[A].g]+shops[B].g)
		}
		if shops[A].s <= i {
			dp[i] = maxint(dp[i], dp[i-shops[A].s]+shops[B].s)
		}
		if shops[A].b <= i {
			dp[i] = maxint(dp[i], dp[i-shops[A].b]+shops[B].b)
		}
	}

	n = dp[n]
	dp = make([]int, n+1)

	for i := 1; i <= n; i++ {
		dp[i] = i
		if shops[B].g <= i {
			dp[i] = maxint(dp[i], dp[i-shops[B].g]+shops[A].g)
		}
		if shops[B].s <= i {
			dp[i] = maxint(dp[i], dp[i-shops[B].s]+shops[A].s)
		}
		if shops[B].b <= i {
			dp[i] = maxint(dp[i], dp[i-shops[B].b]+shops[A].b)
		}
	}

	fmt.Fprintln(writer, dp[n])

	writer.Flush()
}

// Shop g s b
type Shop struct {
	g int
	s int
	b int
}
func maxint(a int, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 202240
N,M=map(int,input().split())
S,C=[],[]
for m in range(M):
    s,c=map(int,input().split())
    S.append(s)
    C.append(c)
for i in range(10**N):
    if len(str(i))==N and all(str(i)[s-1]==str(c) for s,c in zip(S,C)):
        print(i)
        break
else:
    print(-1)


Measured memory_bytes: 3064
class TemplateTree:
  def __init__(self, iterable):
    self.iter_size = self.get_size(iterable)
    self.size = self.iter_size * 2 - 1
    self.value = [None] * self.size
    for i, v in enumerate(iterable):
      self.value[self.iter_size + i - 1] = (-1, v)
    self.set_value(0)
    self.range = [None] * self.size
    self.set_range(0, 0, self.iter_size - 1)
  
  def get_size(self, iterable):
    ret = 1
    x = len(iterable)
    while ret < x:
      ret *= 2
    return ret
  
  def set_range(self, x, left, right):
    self.range[x] = (left, right)
    if left != right:
      self.set_range(x * 2 + 1, left, (right + left) // 2)
      self.set_range(x * 2 + 2, (right + left) // 2 + 1, right)

  def set_value(self, x):
    if x >= self.iter_size - 1:return self.value[x]
    a = self.set_value(x * 2 + 1)
    b = self.set_value(x * 2 + 2)
    if a == None and b == None:
      self.value[x] = None
    elif a == None:
      self.value[x] = b
    elif b == None:
      self.value[x] = a
    else:
      self.value[x] = a
    return self.value[x]

  def update(self, x, val, order, left, right):
    #print(x)
    x_left, x_right = self.range[x]
    if left <= x_left and x_right <= right:
      self.value[x] = (order, val)
    elif right < x_left or x_right < left:
      pass
    else:
      self.update(x * 2 + 1, val, order, left, right)
      self.update(x * 2 + 2, val, order, left, right)
      
  def query(self, x, order, value):
    if x < 0:
      return value
    x_order, x_val = self.value[x]
    if order < x_order:
      return self.query((x - 1) // 2, x_order, x_val)
    else:
      return self.query((x - 1) // 2, order, value)

  def print_tree(self):
    print(self.value)
    print(self.range)

n, q = map(int, input().split())
INF = 2 ** 31 - 1
tree = TemplateTree([INF] * n)

for j in range(q):
  lst = list(map(int, input().split()))
  if lst[0] == 0:
    s, t, x = lst[1:]
    tree.update(0, x, j, s, t)
  else:
    i = lst[1]
    print(tree.query(tree.iter_size - 1 + i, -2, 0))





Measured memory_bytes: 48392
import java.util.Scanner;

/**
 * Created by enpingkuang on 2020/9/11 11:31 下午
 */
public class Main {
    private static int[] prime = new int[1000001];
    private static int[] primeArray = new int[1000005];
    private static boolean[] vis = new boolean[1000001];

    private static int primeNumber = 0;
    private static int gcd(int a,int b){
        if(b == 0){
            return a;
        }
        return gcd(b,a%b);
    }

    private static void getPrime(){
        for(int i = 2;i<=1000000;i++){
            if(prime[i] == 1){
                continue;
            }
            primeArray[primeNumber++] = i;
            for(int j = 2;j*i<=1000000;j++){
                prime[j*i] = 1;
            }
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        getPrime();
        boolean first = true;
        boolean second = false;
        int tmp_gcd = 0;
        for(int i = 0;i<n;i++){
            int x = scanner.nextInt();
            first = resolve(first,x);
            tmp_gcd = gcd(x,tmp_gcd);
            if(tmp_gcd == 1){
                second = true;
            }
        }
        if(first){
            System.out.println("pairwise coprime");
        }else{
            if(second){
                System.out.println("setwise coprime");
            }else{
                System.out.println("not coprime");
            }
        }
    }

    private static boolean resolve(boolean flag,int x){
        if (!flag) {
            return false;
        }
        int tmp = x;
        while (tmp != 1) {
            for (int i = primeNumber -1; i >=0; i--) {
                if (primeArray[i] > tmp) {
                    continue;
                }
                if (tmp % primeArray[i] == 0) {
                    if (vis[primeArray[i]]) {
                        return false;
                    }
                    vis[primeArray[i]] = true;
                    while (tmp != 1 && tmp % primeArray[i] == 0){
                        tmp /= primeArray[i];
                    }
                    break;
                }
            }
        }
        return true;
    }
}


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

int main(void) {
	int c[ 3 ][ 3 ];
	int a[ 3 ];
	int b[ 3 ];
	int n;                      //左上の数
	for (int i = 0;i < 3;i++)   //入力
		for (int j = 0;j < 3;j++)
			cin >> c[ i ][ j ];
	n = c[ 0 ][ 0 ];
	for (int i = 0;i < 3;i++)   //全体から左上の数を引く
		for(int j = 0;j < 3;j++)
			c[ i ][ j ] -= n;
	for (int i = 0;i < 3;i++)   //成り立つとしたときの a を置く
		a[ i ] = c[ i ][ 0 ];
	for (int i = 0;i < 3;i++)   //成り立つとしたときの b を置く
		b[ i ] = c[ 0 ][ i ];
	for (int i = 0;i < 3;i++)   //仮定した a,b が実際にあうか確かめる。
		for (int j = 0;j < 3;j++) {
			if (c[ i ][ j ] != a [ i ] + b [ j ]) {
				cout << "No" << endl;
				return 0;
			}
		}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  const double pi=3.141592653589793;
  double a,b,x; cin>>a>>b>>x;
  cout<<setprecision(20);
  double left=0.0,right=90.0,mid;
  if(a*a*b>=2.0*x){
    while(right-left>1e-10){
      mid=(right+left)/2.0;
      if(a*b*b<=2*x*tan(mid*pi/180.0)) right=mid;
      else left=mid;
    }
  }else{
    while(right-left>1e-10){
      mid=(right+left)/2.0;
      if(a*a*(2.0*b-a*tan(mid*pi/180.0))<=2.0*x) right=mid;
      else left=mid;
    }
  }
  cout<<(right+left)/2.0<<endl;
}


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

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

  if(a>=1 && a<10 && b>=1 && b<10)
    cout << a*b;
  else
  {
    cout << "-1";
  }

}


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

using namespace std;

int main(){

    vector <int> A(5);
    vector <int> A_dig(5);
    

    for(int i = 0; i < 5; i++){
        cin >> A[i];
        A_dig[i] = 10 - (A[i] % 10);

        if (A_dig[i] == 10) {
            A_dig[i] = 0;
        }
    }

    int dig_max = 0;

    for(int i = 0; i < 5; i++){
        if (dig_max <= A_dig[i]) {
            dig_max = A_dig[i];
        }
    }
    
    int sum = 0;
    for(int i = 0; i < 5; i++){
        sum += A[i] + A_dig[i];
    }
    sum -= dig_max;

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

vector<int> G[1 << 17];

int cnt = 0;
void calcnum(int root, int from) {
	int tmp = 0;
	rep(j, G[root].size()) {
		int to = G[root][j];
		if (to == from)continue;
		calcnum(to, root); tmp++;
	}
	cnt += tmp / 2;
	if (root == 0 && tmp % 2)cnt++;
}
int c;
int dfs(int root, int from) {
	vector<int> v;
	rep(j, G[root].size()) {
		int to = G[root][j];
		if (to == from)continue;
		int cto = dfs(to, root);
		if (cto == c) {
			cnt++;
		}
		else {
			v.push_back(cto);
		}
	}
	sort(v.begin(), v.end());
	int len = v.size();
	multiset<int> mt;
	rep(i, len)mt.insert(v[i]);
	vector<int> rest;
	while(len) {
		cnt++;
		auto itr = mt.end(); itr--;
		int z = *itr; mt.erase(mt.find(z)); len--;
		int r = c - z;
		if (mt.count(r)) {
			mt.erase(mt.find(r)); len--;
		}
		else {
			mt.insert(r);
			auto itr2 = mt.find(r);
			if (itr2 == mt.begin()) {
				mt.erase(itr2);
				rest.push_back(z);
				continue;
			}
			itr2--; mt.erase(r);
			mt.erase(itr2); len--;
		}
	}
	if (rest.size()) {
		cnt--;
		return rest[rest.size() - 1] + 1;
	}
	else return 1;
}
int ansa;
bool test(int x) {
	c = x; cnt = 0;
	int u = dfs(0, -1) - 1; if (u > 0)cnt++;
	return cnt == ansa;
}
void solve() {
	int n; cin >> n;
	rep(i, n - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	calcnum(0, -1);
	ansa = cnt;
	int le = 0, ri = n;
	while (ri - le > 1) {
		int mid = (ri + le) / 2;
		if (test(mid)) {
			ri = mid;
		}
		else {
			le = mid;
		}
	}
	cout << ansa << " " << ri << endl;
}
int main() {
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 25088
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <random>

using namespace std;
using ll = long long;

ll A, B, C;

void input() {
    cin >> A >> B >> C;
}

bool solve() {
    return A == B and B == C;
}

int main() {
    input();
    cout << (solve() ? "Yes" : "No") << endl;
    
    return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val k = readLine()!!.toInt()
    val xs = readLine()!!.split(' ').map { it.toInt() }

    xs.map { Math.min(it, Math.abs(it - k)) * 2 }
            .sum()
            .let { println(it) }
}


Measured memory_bytes: 38076
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int n;
string s;

int main() {
    cin >> n >> s;
    int ans = 0;
    for(int i = 0; i < n; ++i) {
        int check = i;
        vector<bool> alpfst(26, false);
        vector<bool> alpsnd(26, false);
        for(int j = 0; j < check; ++j) {
            alpfst.at((int)s.at(j)-97) = true;
        }
        for(int j = check; j < n; ++j) {
            alpsnd.at((int)s.at(j)-97) = true;
        }

        int cnt = 0;
        for(int k = 0; k < 26; ++k) {
            if(alpfst.at(k) == alpsnd.at(k)) {
                if(alpfst.at(k)) cnt++;
            }
        }

        chmax(ans, cnt);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    _ = int(input())
    A = [int(i) for i in input().split()]
    cnt_minus = 0
    zero_flag = False
    for i, a in enumerate(A):
        if a < 0:
            cnt_minus += 1
        elif a == 0:
            zero_flag = True

    ans = 0
    if cnt_minus % 2 == 0 or zero_flag:
        ans = sum(abs(a) for a in A)
    else:
        ans = sum(abs(a) for a in A) - min(abs(a) for a in A) * 2
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 64752
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.LongStream;

public class Main {

	private final int n;
	private final List<Long> a;
	private long[][] dp;
	private long[] prefixSums;
	private long[] suffixSums;

	public Main(int n, List<Long> a) {
		this.n = n;
		this.a = a;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Long> a = LongStream.range(0, n).map(i -> sc.nextLong()).boxed().collect(Collectors.toList());

		new Main(n, a).solve();
	}

	private void solve() {
		dp = new long[n][n];
		prefixSums = new long[n];
		suffixSums = new long[n];
		Arrays.fill(prefixSums, -1);
		Arrays.fill(suffixSums, -1);

		for (int i = 0; i < n; i++) {
			Arrays.fill(dp[i], -1);
		}

		System.out.println(best(0, n - 1));
	}

	private long best(int from, int to) {
		if (from == to) return 0;
		if (dp[from][to] != -1) return dp[from][to];

		long best = Long.MAX_VALUE;
		for (int lastFromLeft = from; lastFromLeft < to; lastFromLeft++) {
			best = Math.min(best,
				sumBetween(from, lastFromLeft) + sumBetween(lastFromLeft + 1, to) +
							best(from, lastFromLeft) + best(lastFromLeft + 1, to));
		}

		dp[from][to] = best;

		return best;
	}

	private long sumBetween(int l, int r) {
		return prefixSum(r) - (l == 0? 0 : prefixSum(l - 1));
	}

	private long prefixSum(int lastFromLeft) {
		if (lastFromLeft == 0) return a.get(0);
		if (prefixSums[lastFromLeft] != -1) return prefixSums[lastFromLeft];
		return prefixSums[lastFromLeft] =
				a.get(lastFromLeft) + prefixSum(lastFromLeft - 1);
	}

}


Measured memory_bytes: 47404
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int cou[5002];
short int lis[5002][5002];
int main(){
    int N,M;
    cin>>N>>M;
    for(int i=0;i<M;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        cou[b]++;
        lis[a][b]=1;
        lis[b][a]=-1;
    }
    int lastflg=0;
    for(int i=0;i<N;i++){
        int mina=100000,minb=100000,flg=0;
        for(int j=0;j<N;j++){
            if(cou[j]<minb)mina=j,minb=cou[j],flg=0;
            else if(cou[j]==minb)flg=1;
        }
        cout<<mina+1<<endl;
        lastflg=max(lastflg,flg);
        cou[mina]=1000000;
        for(int j=0;j<N;j++){
            lis[mina][j]=1;
        }
        for(int j=0;j<N;j++){
            if(lis[j][mina]==0&&mina!=j){
                lis[j][mina]=-1;
                cou[j]++;
            }
        }
    }
    cout<<lastflg<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main(){
  ll N, tmp;
  cin >> N;
  ll sumA = 0;
  ll An;
  vector<ll> A;
  for (int i=0; i<N; i++){
    cin >> tmp;
    A.push_back(tmp);
    if (i < N - 1){
    	sumA += ((i + 1) % 2 == 0 ? tmp : -tmp);
    }
    else{
      An = tmp;
    }
  }
  vector<ll> x;
  x.push_back(An - sumA);
  for (int i=1; i<N; i++){
   	ll xtmp = A[i - 1] - x.back() / 2;
    x.push_back(2*xtmp);
  }
  for (ll a : x){
    cout << a << " ";
  }
  cout << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  string s;
  cin>>s;
  int n=s.size();
  int ans=0;
  REP(i, n/2){
    if(s[i]!=s[n-i-1]){
      ++ans;
    }
  }
  cout<<ans<<'\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int cur = 0;
    while (a > 0 && c > 0)
    {
        if (cur)
            a -= d;
        else
            c -= b;
        cur = 1 - cur;
    }
    if (a > 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    GAME_OVER;
}

Measured memory_bytes: 3652
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9184
from collections import deque

h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1
visited = [[0 for i in range(w)] for j in range(h)] # いったところ
t = [list(input()) for _ in range(h)]
d = deque([(Ch, Cw)])
d2 = deque()
ans = 0
a = [(1,0),(-1,0),(0,1),(0,-1)]
b = range(-2, 3)

while True:
  # 移動A
  while len(d) != 0:
    Th, Tw = d.popleft()
    d2.append((Th, Tw))
    if (Th,Tw) == (Dh, Dw):
      print(ans)
      exit()
    for i, j in a:
      _h,_w = Th + i, Tw + j
      _p = (_h, _w)
      if 0 <= _h < h and 0 <= _w < w and t[_h][_w] == '.' and visited[_h][_w] == 0:
        d.append(_p)
        visited[_h][_w] = 1
  # 移動B
  ans += 1
  while len(d2) != 0:
    Th, Tw = d2.popleft()
    for i in b :
      for j in b :
        _h,_w = Th + i, Tw + j
        _p = (_h, _w)
        if 0 <= _h < h and 0 <=  _w < w and t[_h][_w] == '.' and visited[_h][_w] == 0:
          d.append(_p)
          visited[_h][_w] = 1
  if len(d) == 0:
    print('-1')
    exit()


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

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >> H.at(i);
  }
  if(N==1){
    cout << 0 << endl;
  }else{
    vector<int> d(N);
    for(int i=0;i<N-1;i++){
      d.at(i)=H.at(i)-H.at(i+1);
    }
    d.at(N-1)==-100;
    int count=0;
    for(int i=0;i<N-1;i++){
      int tmp=0;
      while(d.at(i)>=0&&i<N-1){
        tmp++;
        i++;
      }
      if(tmp>count){
        count=tmp;
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    string ans;
    if(a==b) ans = "Draw";
    else if(a==1) ans = "Alice";
    else if(b==1) ans = "Bob";
    else if(a>b) ans = "Alice";
    else ans = "Bob";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main () {
    string S;
    cin >> S;
    int A = 0;
    int B = 0;
    int C = 0;
    for(int i = 0; i < S.size(); i++){
        if(S.at(i) == 'a'){
            A++;
        }
        if(S.at(i) == 'b'){
            B++;
        }
        if(S.at(i) == 'c'){
            C++;
        }
    }
    if(abs(A - B) <= 1 && abs(B - C) <= 1 && abs(A - C) <= 1){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}


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

int main() {
    
    int N;
    cin >> N;
    int A[2][N];
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < N; j++){
            cin >> A[i][j];
        }
    }

    int max_ans = -1;
    for(int i = 0; i < N; i++){
        int ans = 0;

        for(int j = 0; j <= i; j++){
            ans += A[0][j];
        }
        for(int j = i; j < N; j++){
            ans += A[1][j];
        }
        max_ans = max(max_ans, ans);
    }
    cout << max_ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;
#define int long long int
#define mod 1000000007
void dfs(int src,vector<int> adj[],int &here,bool visited[])
{
	if(visited[src])
	   return ;
	else
	{
		visited[src]=true;
		here++;
		for(int x:adj[src])
		   dfs(x,adj,here,visited);
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,m;
	cin>>n>>m;
	int answer=0;
	int j;
	vector<int> adj[n+1];
	for(j=0;j<m;j++)
	{
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	bool visited[n+1]={false};
	for(j=1;j<=n;j++)
	{
		int here=0;
		if(!visited[j])
		{
			dfs(j,adj,here,visited);
			answer=max(answer,here);
		}
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 24076
#最小領域木
#ABC065D - Built?
#https://atcoder.jp/contests/abc065/tasks/arc076_b

#自己考察TLE

import sys

n = int(input())
cad = []
lst = []
for i in range(n):
    x, y =  list(map(int,input().split()))
    lst.append([x,y,i])
lstx = lst.sort(key = lambda x: x[0])
for i in range(n-1):
    cad.append([lst[i+1][0] - lst[i][0],lst[i+1][2],lst[i][2]])
lsty = lst.sort(key = lambda x: x[1])
for i in range(n-1):
    cad.append([lst[i+1][1] - lst[i][1],lst[i+1][2],lst[i][2]])

cad.sort()

class UnionFind():
    
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
 
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
 
    def size(self, x):
        return -self.parents[self.find(x)]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
 
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
 
    def group_count(self):
        return len(self.roots())
 
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
 
    def __str__(self):
        return '\n'.join('{}: {}'.format(r,self.members(r)) for r in self.roots())

h = UnionFind(n)
cost = 0
count = 0
for i in range(len(cad)):
    a = cad[i][1]
    b = cad[i][2]
    c = cad[i][0]
    if  not h.same(a,b):
        h.union(a,b)
        cost += c
        count += 1
    if count == n-1:
        print(cost)
        sys.exit()

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

#define int long long
#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second

main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    string s;
    int k;
    long long ans = 0;
    vi v;
    cin >> s >> k;
    int cur = 1;
    for (int i = 1; i < (int) s.size(); i++) {
        if (s[i] == s[i - 1]) cur++;
        else {
            ans += cur / 2;
            v.pb(cur);
            cur = 1;
        }
    }
    ans += cur / 2;
    v.pb(cur);
    if (v.size() == 1) return cout << 1LL * s.size() * k / 2, 0;
    ans = ans * k;
    if (s[0] == s.back()) {
        int u = v[0];
        int uu = v.back();
        int foo = u + uu;
        ans -= (k - 1) * (u / 2 + uu / 2);
        ans += (k - 1) * (foo / 2);
    }
    cout << ans;
    return 0;
}

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

using namespace std;

int subordinates[654321];

int main(){
    
    int num_people;
    cin >> num_people;
    for(int i=0; i<num_people-1; i++){
        int boss;
        cin >> boss;
        subordinates[boss-1] += 1;
    }
    for(int i=0; i<num_people; i++){
        cout << subordinates[i] << '\n';
    }
}

Measured memory_bytes: 4304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

int main()
{
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  s[k-1] += 32;
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
N = input()

if N[-1] == '2' or  N[-1] == '4' or N[-1] == '5' or N[-1] == '7' or N[-1] == '9':
  print('hon')
elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8':
  print('pon')
elif N[-1] == '3':
  print('bon')

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

using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    int legs = 0;
    for(int i=0; i<=x; i++){
        int j = x - i;
        legs = 2*i + 4*j;
        if(legs == y){
            cout << "Yes" << '\n';
            return 0;
        }
    } 
    cout << "No" << '\n';
    return 0;
}

Measured memory_bytes: 3616
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    int x; cin >> x;

    int ans = 0;

    while (x >= 500) {
        x -= 500;
        ans += 1000;
    }

    while (x >= 5) {
        x -= 5;
        ans += 5;
    }

    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 888
//17:48
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c,d;
	while(cin>>a>>b>>c>>d) {
		cout<<(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d) ? "Yes":"No")<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		scan.close();
		Pattern p = Pattern.compile("3");
		for(int i=1;i<=n;i++){
			if(i%3==0){
				System.out.print(" "+i);
			}else{
				Matcher m = p.matcher(Integer.toString(i));
				if(m.find())
					System.out.print(" "+i);	
				}
		}
		System.out.println("");
	}
}

Measured memory_bytes: 24232
#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);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	ll n;
	cin>>n;
	ll ans = 0;
	if(n==2){
		cout<<1<<endl;
		return 0;
	}
	reps(k, (n-1)/2){
		ll add = 1;
		add *= nCr(n-k-2, k-1); add %= MOD;
		add *= kaijo(k-1); add %= MOD;
		add *= kaijo(n-k-1); add %= MOD;
		add *= 2;
		add *= (n-k); add %= MOD;
		add *= k; add %= MOD;
		ans += add;
		ans %= MOD;
	}

	reps(k, (n-2)/2){
		ll add = 1;
		add *= nCr(n-k-3, k-1);add%=MOD;
		add *= kaijo(k);add%=MOD;
		add *= kaijo(n-k-2);add%=MOD;
		add *= n-k-1;add%=MOD;
		add *= k+1;add%=MOD;
		ans += add;
		ans %=MOD;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 10092
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

int main(void){
    int a,b,counter = 0;
    scanf("%d %d",&a,&b);
    int i,j,val,ten = 10000;
    int s[5];
    for(i=a;i<=b;i++){
        val = i;
        for(j=0;j<5;j++){
            s[j] = val/ten;
            val = val-s[j]*ten;
            ten = ten/10;
        }
        ten = 10000;
        if(s[0]==s[4]&&s[3]==s[1]){
            counter++;
        }
    }
    printf("%d\n",counter);
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
    public Main(){
        Scanner SC = new Scanner(System.in);

        int N = Integer.parseInt(SC.next());
        int M = Integer.parseInt(SC.next());
        int[][] H = new int[N][2];
        for(int i=0;i<N;i++){
            H[i][0] = Integer.parseInt(SC.next());
            H[i][1] = 1;
        }
        int A,B;
        for(int i=0;i<M;i++){
            A = Integer.parseInt(SC.next())-1;
            B = Integer.parseInt(SC.next())-1;
            if(H[A][0] > H[B][0]){
                H[B][1] = 0;
            } else if(H[A][0] < H[B][0]){
                H[A][1] = 0;
            } else {
                H[A][1] = 0;
                H[B][1] = 0;
            }
        }

        int result = 0;
        for(int i=0;i<N;i++){
            if(H[i][1] == 1) result++;
        }

        System.out.println(result);

    }

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


Measured memory_bytes: 62360
#include<stdio.h>

int main(void){
    int L, R, d, i=0, count=0;
    scanf("%d %d %d", &L, &R, &d);

    for(i=L; i<R+1; i++){
        if(i % d == 0){
            count++;
        }
    }

    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
int main(void)
{
	int a,b,d,r;
	double f;
	scanf("%d %d %d",&a,&b);
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	printf("%d %d %lf\n",d,r,f);
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	int ans = 0;
	int v[25], c[25];
	rep(i, n){
		cin >> v[i];
	}
	rep(i, n) cin >> c[i];
	rep(i, n){
		ans += max(0, v[i] - c[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import itertools

N = int(input())

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

result = 0

for c in itertools.combinations(L, 3):
    if len(set(c)) == 3:
        s = sorted(c)
        if s[0] + s[1] > s[2]:
            result += 1

print(result)

Measured memory_bytes: 9176
from collections import deque
def main():
  h,w=map(int,input().split())
  ans,q=0,deque()
  visited=[[0 if j=="#" else -1 for j in input()] for _ in range(h)]
  q=deque([(i,j) for i in range(h) for j in range(w) if visited[i][j]==0])
  while q:
    x,y=q.popleft()
    for i,j in ((0,1),(1,0),(-1,0),(0,-1)):
      newx,newy=x+i,y+j
      if 0<=newx<h and 0<=newy<w:
        if visited[newx][newy]==-1:
          visited[newx][newy]=visited[x][y]+1
          q.append((newx,newy))
          ans=max(ans,visited[newx][newy])
  return print(ans)
if __name__=='__main__':
  main()


Measured memory_bytes: 111084
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,x,y,z,p,q;
    ll n,m,tmp;
    string s[200000];
    string str1,str2;
    ll sum=0;
    ll strr[200005];
    cin>>j>>str1>>str2;
    rep(i,j){
        cout<<str1[i]<<str2[i];
    }
    ln;
    return 0;
}

Measured memory_bytes: 1792
#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()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    int n;
    cin >>n;
    vector<int> a[2];
    rep(i,2){
        a[i] = vector<int>(n);
        rep(j,n) cin >>a[i][j];
    }

    int ans = 0;
    rep(i,n){
        int t = 0;
        rep(j,i+1) t += a[0][j];
        for(int j=i; j<n; ++j) t += a[1][j];
        ans = max(ans, t);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a,b=map(int,input().split())
s=input()
f=True
for i in range(a+b+1):
  if i==a:
    if s[i]!="-":
      f=False
      break
  elif not s[i].isdigit():
    f=False
    break
if f:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    int x, y;
    cin >> x >> y;

    Cout(x + y / 2);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define MOD 998244353
template<typename ty1,typename ty2>
inline int add(ty1 x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x += y; return x < MOD ? x : x - MOD;
}
template<typename ty1,typename ty2>
inline void addto(ty1 &x, ty2 y) {
		  if(y>=MOD)y%=MOD;
		  if(x>=MOD)x%=MOD;
	      x += y; if (x >= MOD) x -= MOD;
}
template<typename ty1,typename ty2>
inline int sub(ty1 x, ty2 y) {
		if(y>=MOD)y%=MOD;
		 if(x>=MOD)x%=MOD;
        x -= y; return x < 0 ? x + MOD : x;
}
template<typename ty1,typename ty2>
inline void subto(ty1 &x, ty2 y) {
	if(y>=MOD)y%=MOD;
	if(x>=MOD)x%=MOD;
    x -= y; if (x < 0) x += MOD;
}
template<typename ty1,typename ty2>
inline int mul(ty1 x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        return 1ll * x * y % MOD;
}
template<typename ty1,typename ty2>
void multo(ty1 &x, ty2 y) {
        if(y>=MOD)y%=MOD;
		if(x>=MOD)x%=MOD;
        x=1ll * x * y % MOD;
}
 
 
long long int ppow(long long int i, long long int j){
		long long int res = 1LL;
		while (j){
			if ((j & 1LL)){
				res *= i;
				if (res >= MOD){
					res %= MOD;
				}
			}
			j >>= 1;
			i *= i;
			if (i >= MOD){
				i %= MOD;
			}
		}
		return res;
	}
class Combination{
	
public:
	vector<long long int> k;
	vector<long long int> r;
	void resize(int N){
		k.resize(N + 2);
		r.resize(N + 2);
		k[0] = 1;
		for (int i = 1; i < N+2; i++){
			k[i] = k[i - 1];
			k[i] *= i;
			if (k[i] >= MOD)k[i] %= MOD;
		}
		long long int al = k[k.size() - 1];
		long long int iv = ppow(k[k.size() - 1],MOD-2);
		r[k.size() - 1] = iv;
		for (int i = (int)(r.size()) - 2; i >= 0; i--){
			r[i] = r[i + 1] * (i + 1);
			if (r[i] >= MOD){
				r[i] %= MOD;
			}
		}
	}
	long long int C(int a, int b){
		if (a < b)return 0;
		long long int up = k[a];
		long long int dw = r[b] * r[a - b];
		dw %= MOD;
		up *= dw;
		up %= MOD;
		return up;
	}
	long long int H(int a, int b){
		return C(a + b - 1, b);
	}
	long long int catalan_number(int n){
		return (C(2 * n, n) + MOD - C(2 * n, n - 1)) % MOD;
	}
};
Combination C;

#define MAX 4002
char buf[MAX];
string s;
vector<int> posw;
vector<int> posb;
int dp[MAX][MAX];
int main(){
	scanf("%s",buf);
	s=buf;
	for(int i=0;i<s.size();i++){
		if(s[i]=='0'){
			posw.push_back(i);
			posw.push_back(i);
		}
		if(s[i]=='1'){
			posw.push_back(i);
			posb.push_back(i);
		}
		if(s[i]=='2'){
			posb.push_back(i);
			posb.push_back(i);
		}
	}
	dp[0][0]=1;
	int n=s.size();
	for(int i=0;i<n*2;i++){
		for(int j=0;j<=i;j++){
			if(dp[i][j]==0)continue;
			int white=j;
			int black=i-j;
			if(white<posw.size()&&posw[white]<=i){
				addto(dp[i+1][j+1],dp[i][j]);
			}
			if(black<posb.size()&&posb[black]<=i){
				addto(dp[i+1][j],dp[i][j]);
			}
		}
	}
	int ret=dp[n*2][posw.size()];
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 60544
#include <cstdio>
#include <iostream>
#include <string>

std::string s;
int a[30];

int main(){
	std::cin >> s;
	for(int i=0; i<s.size(); ++i)
		++a[s[i]-'a'];
	for(int i=0; i<27; ++i)
		if(a[i] == 0){
			if(i == 26) printf("None\n");
			else printf("%c\n", 'a'+i);
			break;
		}
}

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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    int n = s.size();
    long c = 0;
    long res = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'A') {
            c++;
        } else if (i < n - 1 && s[i] == 'B' && s[i + 1] == 'C') {
            res += c;
            i++;
        } else {
            c = 0;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 720