akhauriyash/Code-Regression huggingface dataset:
import itertools

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

comb_ab = []
for a, b in itertools.product(A, B):
    comb_ab.append(sum([a, b]))

comb_ab_top = sorted(comb_ab, reverse=True)[:K]

comb_abc = []
for ab, c in itertools.product(comb_ab_top, C):
    comb_abc.append(sum([ab, c]))

ans = sorted(comb_abc, reverse=True)[:K]
print(*ans, sep='\n')


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

using namespace std;

struct UnionFind{
  vector<int> data;
  UnionFind(int n)
  {
    data.assign(n, -1);
  }
  int find(int k)
  {
    if(data[k] < 0) return k;
    return data[k] = find(data[k]);
  }
  void unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return;
    if(x > y) swap(x, y);
    data[x] += data[y];
    data[y] = x;
  }
  int size(int k)
  {
    return -data[find(k)];
  }
};

int memo[1010];

int fib(int v)
{
  if(v <= 0) return 1;
  if(~memo[v]) return memo[v];
  return memo[v] = (fib(v-1) + fib(v-2)) % 1001;
}

int main()
{
  int V, d;
  int F[1010];
  memset(memo, -1, sizeof(memo));
  for(int i = 0; i < 1000; i++) F[i] = fib(i+1);
  while(cin >> V >> d){
    UnionFind uf(V);
    for(int i = 0; i < V; i++){
      for(int j = i+1; j < V; j++){
	if(abs(F[i] - F[j]) < d) uf.unite(i, j);
      }
    }
    int cnt = 0;
    for(int i = 0; i < V; i++){
      if(uf.data[i] < 0) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1208
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Thu Jun 14 23:23:31 2018
//
package main

import (
	"fmt"
	"sort"
)

const MOD int = 1e9 + 7

var N int
var a, b []int

func main() {
	fmt.Scan(&N)
	a = make([]int, N)
	b = make([]int, N)
	for i := range a {
		fmt.Scan(&a[i])
	}
	for i := range b {
		fmt.Scan(&b[i])
	}
	sort.Ints(a)
	sort.Ints(b)

	ans := 1
	seta := make([]int, 0)
	setb := make([]int, 0)
	indexa := 0
	indexb := 0
	for i := 0; i < 2*N; i++ {
		if indexb >= len(b) || (indexa < len(a) && a[indexa] < b[indexb]) {
			if len(setb) > 0 {
				ans *= len(setb)
				ans %= MOD
				setb = setb[1:]
			} else {
				seta = append(seta, a[indexa])
			}
			indexa++
		} else {
			if len(seta) > 0 {
				ans *= len(seta)
				ans %= MOD
				seta = seta[1:]
			} else {
				setb = append(setb, b[indexb])
			}
			indexb++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7040
#include <stdio.h>
int main()
{
	int inputA;
	int	inputB;
	int	printOutput;

	scanf("%d%d", &inputA, &inputB);

	printOutput = inputA - (2 * inputB);
	if (printOutput < 0)
	{
		printOutput = 0;
	}
	
	printf("%d \n", printOutput);
}

Measured memory_bytes: 128
@K=<>!~$"+$';
$K[0]&($t=1<<$_)?push@K,($K[0]|$t-1)^$t:0for 1..29;
for(<>){
	($A,$B)=split;
	$i=0;
	($A|$_)<=$_&&($x[$i]+=$B),$i++for@K
}
printf'%d',sort{$b<=>$a}@x


Measured memory_bytes: 17280
import scala.io.StdIn
import scala.collection.mutable.ArrayBuffer

/*
 ret
 http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2232735#1
 */
object Main extends App {

  val n = StdIn.readLine().trim.toInt
  class Point(val x: Double, val y: Double){
    override def toString: String = {
      f"$x%.8f $y%.8f"
    }
  }
  
  final val start = new Point(0, 0)
  final val end   = new Point(100, 0)
  final val th = scala.math.Pi * 60.0 / 180.0
  final val cos = math.cos(th)
  final val sin = math.sin(th)


  @inline def calcuPoint(p1: Point, p2: Point, a: Double, b: Double) = new Point((a*p1.x+b*p2.x)/3.0, (a*p1.y+b*p2.y)/3.0)
  
  
  def koch(d: Double, p1: Point, p2: Point, ret: ArrayBuffer[Point]): Unit = {
    if(d != 0){
      val s = calcuPoint(p1, p2, 2.0, 1.0)
      val t = calcuPoint(p1, p2, 1.0, 2.0)
      val tsx = t.x - s.x
      val tsy = t.y - s.y
      val u = new Point(tsx*cos - tsy*sin + s.x,
                        tsx*sin + tsy*cos + s.y)
      
      koch(d-1, p1, s, ret)
      // println(s)
      ret += s
      
      koch(d-1, s, u, ret)
      //println(u)
      ret += u
      
      koch(d-1, u, t, ret)
      // println(t)
      ret += t

      koch(d-1, t, p2, ret)

    }
  }
  
  var result = ArrayBuffer.empty[Point]

  //println(start)
  result += start
  koch(n, start, end, result)
  result += end
  
  //result.foreach(println)
  println(result.mkString(f"%n"))
  
}


Measured memory_bytes: 59724
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  ll X=0;
  vector<int> a(n);
  REP(i,n){
    cin >> a[i];
    X += a[i];
  }
  ll x = 0;
  ll ans = 1e+18;
  REP(i,n-1){
    x += a[i];
    ans = min(ans, abs(X-2*x));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
N = int(input())
#A = [int(i) for i in input().split()]
A = list(map(int,input().split()))

def gcp(a,b):
    if b == 0:
        return a
    else:
        a,b = b,a%b
        return gcp(a,b)

a = A[0]
for i in range(1,N):
    a = gcp(a,A[i])
print(a)

Measured memory_bytes: 14252
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
alice = 0
bob = 0
n = 0
while len(a) > 0:
    if n == 0:
        alice += a.pop()
        n = 1
    else:
        bob += a.pop()
        n = 0
print(alice - bob)

Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    let (a,b) = {
        let xs = read_vec_i64();
        (xs[0], xs[1])
    };
    let res = a <= 8 && b <= 8;
    println!("{}", if res { "Yay!" } else { ":(" });
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec_i64<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}


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

using namespace std;

#define ll long long

int main()
{
    string a;
    cin>>a;
    int k=0,l=0;
    for(int i=0;a[i]!='\0';i++)
    {
        while(a[i]=='R')
        {
            k++;
            i++;
        }
        l=max(k,l);
        k=0;
    }
    cout<<l;

}


Measured memory_bytes: 3624
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <list>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)

int main(){
    ll n,r=0,b=0;
    string s;
    cin >> n >> s;
    rep(i,n){
        if(s[i] == 'R') r++;
        else b++;
    }
    if(r>b) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main(){
        int n;
        int min = 1000000;
        int max = -1000000;
        int i;
        int a;
        long sum = 0;

        cin >> n;
        for(i = 0; i < n; i++)
        {
                cin >> a;
                if(a < min) min = a;
                if(a > max) max = a;
                sum = sum + a;
        }
        cout << min << " " << max << " " << sum << endl;

        return 0;
}

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

#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int N,K;
cin>>N>>K;
vi a(N);
for(auto& x: a)
  cin>>x;
sort(all(a));
ll ans=0;
for(int i=0;i<K;i++)
  ans+=a[i];
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
using namespace std;

int main(){
    int A, B, C;
    cin >> A >> B >> C;
    //所持金から聞ける回数
    int max = B/A;
    //cout << max;
    if(max>C){
        cout << C;
    }else
    {
        cout << max;
    }
}

Measured memory_bytes: 256
S = input()
check = True
for i in range(len(S)):
    if (i+1) % 2 == 0:
        if S[i] == "R":
            check = False
    else:
        if S[i] == "L":
            check = False
if check == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
N = int(input())
S = []
for i in range(N):
    S.append(input())

wod = set(S[0])
for i in range(1, N):
    wod = wod & set(S[i])
    
wod = sorted(wod)
check = [10000] * len(wod)


for i in range(len(wod)):
    for s in S:
        check[i] = min(check[i], s.count(wod[i]))

ans = ''

for i in range(len(wod)):
    ans += wod[i]*check[i]
print(ans)

Measured memory_bytes: 3064
def main():
    n, m = [int(e) for e in input().split()]
    X = [int(e) for e in input().split()]

    if n >= m:
        print(0)
        exit()

    X.sort()
    Xd = []
    prev = X[0]
    for i in range(1, m):
        Xd.append(X[i] - prev)
        prev = X[i]

    Xd.sort()
    for i in range(n - 1):
        Xd.pop()

    print(sum(Xd))

if __name__ == "__main__":
    main()


Measured memory_bytes: 56744
a, b = input().split()
 
a = int(a)
b = int(b)
 
count = 0
 
if b == 1:
    print("0")
else:
    while True:
        if b <= a:
            count += 1
            break
        else:
            b=b-a+1
            count = count + 1
 
    print(count)

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

int  tax(int price, int rate){
    double taxed=price*(100+rate)/100.0;
    return static_cast<int>(taxed);
}

int max(int x, int y){
    if(x<y) return y;
    else return x;
}

int main(){
    int x, y, s;
    int maximum = 0;
    cin >> x >> y >> s;
    while(!(x==0 && y==0 && s==0)){
        maximum=0;
        for(int i = 1; i < s; ++i){
            for(int j = i; j < s; ++j){
                if(tax(i,x) + tax(j,x) == s){
                    maximum = max(maximum, tax(i,y)+tax(j,y));
                }
            }
        }
        cout<<maximum<<"\n";
        cin >> x >> y >> s;
    }
}

Measured memory_bytes: 3036
#include <cstdio>
#include <algorithm>

#define ll long long
#define inf 0x3f3f3f3f
#define il inline
#define int long long

namespace io {

    #define in(a) a=read()
    #define out(a) write(a)
    #define outn(a) out(a),putchar('\n')

    #define I_int int
    inline I_int read() {
        I_int x = 0 , f = 1 ; char c = getchar() ;
        while( c < '0' || c > '9' ) { if( c == '-' ) f = -1 ; c = getchar() ; }
        while( c >= '0' && c <= '9' ) { x = x * 10 + c - '0' ; c = getchar() ; }
        return x * f ;
    }
    char F[ 200 ] ;
    inline void write( I_int x ) {
        if( x == 0 ) { putchar( '0' ) ; return ; }
        I_int tmp = x > 0 ? x : -x ;
        if( x < 0 ) putchar( '-' ) ;
        int cnt = 0 ;
        while( tmp > 0 ) {
            F[ cnt ++ ] = tmp % 10 + '0' ;
            tmp /= 10 ;
        }
        while( cnt > 0 ) putchar( F[ -- cnt ] ) ;
    }
    #undef I_int

}
using namespace io ;

#define N 200010

int n;
int a[N] ; ll ans = 0;

signed main() {
	n = read() ; ll now = 0 ;
	for(int i = 1; i <= n; i ++) a[i] = read() ;
	for(int l = 1 , r = 0 ; l <= n; ) {
		while((now ^ a[r + 1]) == (now + a[r + 1]) && r < n) {
			now ^= (ll)a[++ r] ;
		}
		ans += (ll)(r - l + 1) ;
		now ^= (ll)a[l ++] ;
	}
	outn(ans) ;
	return 0 ;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> a;
    if(n==0){
    cout<<0<<endl;
    return 0;
    }
        while(n!=0){
            a.push_back(abs(n%2));
            n=(n-abs(n%2))/(-2);
        }
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();i++){
        cout<<a.at(i);
    }
    cout<<endl;
}

Measured memory_bytes: 256
n = int(input())
s = str(input())

lst_ans=[]
num_e= s.count("E")
ans = num_e
for i in range(n):
    if s[i] == "E":ans -= 1
    if i != 0:
        if s[i-1]=="W":ans += 1
    lst_ans.append(ans)
print(min(lst_ans))

Measured memory_bytes: 15520
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main() {
    int M;
    cin >> M;
    ll sum = 0;
    ll ans = 0;
    for (int i = 0; i < M; ++i) {
        ll c, d;
        cin >> d >> c;
        sum += c * d;
        ans += c;
    }
    ans--;
    while (sum / 10){
        ans += sum / 10;
        sum = sum % 10 + sum / 10;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    ll K,X;
    cin >> K >> X;
    if(K * 500 >= X){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

#define MOD 1e9+7

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

ll m = MOD;

int main(){
    ll n;
    cin >> n;
    vector<ll> a;
    rep(i, n){
        ll x;
        cin >> x;
        a.push_back(x);
    }
    ll ans=0;
    rep(i, 61){
        ll cnt=0;
        rep(j, n){
            if((a[j]>>i)&1){
                cnt++;
            }
        }
        // cout << cnt << endl;
        ans = (ans + ((((((1LL << i) % m) * cnt) % m) * (n - cnt)) % m)) % m;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7356
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

template <typename T>
inline T gi()
{
	T f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 200003, M = N << 1;

int n, k;
int ton[N];
LL ans;

int main()
{
	//File("");
	n = gi <int> (), k = gi <int> ();
	for (int i = 1; i <= n; i+=1) ++ton[i % k];
	for (int i = 0; i < k; i+=1)
		if ((k - i) * 2 % k == 0)
			ans += (LL)ton[i] * ton[(k - i) % k] * ton[(k - i) % k];
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

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

	ll x,y,z,k;
	cin >> x >> y >> z >> k;
	vector<ll> a(x),b(y),c(z);
	FOR(i,0,x)cin>>a[i];
	FOR(i,0,y)cin>>b[i];
	FOR(i,0,z)cin>>c[i];

	SORT(a);REV(a);
	SORT(b);REV(b);
	SORT(c);REV(c);

	priority_queue< pair<P,P> > q;
	q.push({{a[0]+b[0]+c[0],0},{0,0}});
	set<pair<ll,P>> se;


	while(k--){
		ll m,n,l;
		cout << q.top().first.first << endl;
		m = q.top().first.second;
		n = q.top().second.first;
		l = q.top().second.second;
		q.pop();
		if(m<x-1 && !se.count({m+1,{n,l}}))q.push({{a[m+1]+b[n]+c[l],m+1},{n,l}}),se.insert({m+1,{n,l}});
		if(n<y-1 && !se.count({m,{n+1,l}}))q.push({{a[m]+b[n+1]+c[l],m},{n+1,l}}),se.insert({m,{n+1,l}});
		if(l<z-1 && !se.count({m,{n,l+1}}))q.push({{a[m]+b[n]+c[l+1],m},{n,l+1}}),se.insert({m,{n,l+1}});
	}
}


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

int main() {
  int d;
  scanf("%d", &d);
  if (d == 25) {
    printf("Christmas\n");
  } else if (d == 24) {
    printf("Christmas Eve\n");

  } else if (d == 23) {
    printf("Christmas Eve Eve\n");

  } else {
    printf("Christmas Eve Eve Eve\n");
  }
  return 0;
}


Measured memory_bytes: 256
// 22
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
void _main(int tc) {
  int n;
  cin >> n;
  vector<vector<int>> abc(n, vector<int>(3));
  rep(i, n) {
    cin >> abc[i][0];
    cin >> abc[i][1];
    cin >> abc[i][2];
  }
  vector<vector<int>> mem(n, vector<int>(3));
  mem[n - 1][0] = abc[n - 1][0];
  mem[n - 1][1] = abc[n - 1][1];
  mem[n - 1][2] = abc[n - 1][2];
  // function<int(int, int)> fhappy = [&](int i, int k) -> int {
  //   if (mem[i][k] != 0) return mem[i][k];
  //   rep(j, 3) {
  //     if (k != j) mem[i][k] = max(mem[i][k], abc[i][k] + fhappy(i + 1, j));
  //   }
  //   return mem[i][k];
  // };
  // auto ans = max({fhappy(0, 0), fhappy(0, 1), fhappy(0, 2)});
  // cout << ans << endl;

  rrep(i, n - 1) {
    mem[i][0] = abc[i][0] + max(mem[i + 1][1], mem[i + 1][2]);
    mem[i][1] = abc[i][1] + max(mem[i + 1][0], mem[i + 1][2]);
    mem[i][2] = abc[i][2] + max(mem[i + 1][0], mem[i + 1][1]);
  }
  auto ans = *max_element(all(mem[0]));
  cout << ans << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0);
  return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 11264
import java.util.Scanner;

public class Main{

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

        // input
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();

        // answer
        System.out.println(Math.min(b / a, c));

    }
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

struct Edge {
    int to,cost;
    Edge (int t,int c) {
        to = t; cost = c;
    }
    bool operator>(const Edge& e)const {
        return cost > e.cost;
    } 
    bool operator<(const Edge& e)const {
        return cost < e.cost;
    }
};

int main (void) {
    int H,W;
    cin>>H>>W;
    vector<vector<Edge>> G(10);
    REP(i,10) {
        REP(j,10) {
            int c;
            cin>>c;
            G[j].pb(Edge(i,c)); //辺を逆向きに追加
        }
    }

    //Dijkstraで1をnに変えるのに必要なコストを求める。
    //-> グラフの辺は逆向きなので、
    //   nから1に変えるのに必要なコストを求めることになる（はず）
    priority_queue<Edge,vector<Edge>,greater<Edge>> pq;
    vector<int> dist(10,inf);
    vector<bool> used(10,false);
    dist[1] = 0;
    pq.push(Edge(1,0));
    while(pq.size()) {
        int from = pq.top().to;
        pq.pop();
        if (used[from]) continue;
        used[from] = true;
        REP(i,10) {
            int c = G[from][i].cost;
            int t = G[from][i].to;
            if (dist[t] > c + dist[from]) {
                dist[t] = c + dist[from];
                pq.push(Edge(t,dist[t]));
            }
        }
    }
    ll ans = 0;
    REP(i,H) {
        REP(j,W) {
            int n;
            cin>>n;
            if (abs(n) != 1) {
                ans += dist[n];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.HashSet;

public class Main {

    private static Scanner sc;

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

    private void solve() {
        try {
            int N = sc.nextInt();
            int K = sc.nextInt();
            int[] d = new int[110];
            int[][] A = new int[120][120];

            for(int i=0; i<K; i++) {
                d[i] = sc.nextInt();
                for(int j=0; j<d[i]; j++) {
                    A[i][j] = sc.nextInt();
                }
            }

            HashSet<Integer> set = new HashSet<>();

            for(int i=0; i<K; i++) {
                for(int j=0; j<d[i]; j++) {
                    set.add(A[i][j]);
                }
            }

            System.out.println(N-set.size());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 33960
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

  static class TaskA {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      int n = in.nextInt();
      out.printLine(n * 800 - n / 15 * 200);
    }

  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1) {
        throw new InputMismatchException();
      }
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0) {
          return -1;
        }
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = read();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9') {
          throw new InputMismatchException();
        }
        res *= 10;
        res += c - '0';
        c = read();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) {
        return filter.isSpaceChar(c);
      }
      return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
      boolean isSpaceChar(int ch);

    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void close() {
      writer.close();
    }

    public void printLine(int i) {
      writer.println(i);
    }

  }
}



Measured memory_bytes: 21332
#include <iostream>

using namespace std;

int main()
{
    int a, b, c; cin >> a >> b >> c;
    int startRemainder = a % b;
    bool canSelect = false;

    for (int i = 2; ;i++) {
        if (startRemainder == (a * i) % b) {
            break;
        } else if ((a * i) % b == c) {
            canSelect = true;
        }
    }

    if (canSelect) cout << "YES" << endl;
    else           cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 888
#include<iostream>
using namespace std;
#define df 0
typedef long int li;
const int MOD=1e9+7;

int main(){
  if(df) printf("*debug mode*\n");
  li n,m; cin >>n >>m;

  li sumx=0;
  int a=-(n-1);
  for(int i=0;i<n;i++){
    li x; cin >>x;
    (sumx+=a*x)%=MOD;
    if(df)printf("%d ",sumx);
    a+=2;
  }
  if(df)printf("\n");
  li sumy=0;
  a=-(m-1);
  for(int i=0;i<m;i++){
    li x; cin >>x;
    (sumy+=a*x)%=MOD;
    a+=2;
    if(df)printf("%d ",sumy);
  }
  if(df)printf("\n");
  cout << sumx*sumy%MOD;
}

/// confirm df==0 ///

Measured memory_bytes: 256
from itertools import product
X = list(map(int, input()))
op = {'+':1, '-':-1}

for ops  in product(op, repeat=3):
    v = X[0] + sum([x*op[o] for x,o in zip(X[1:], ops)])
    if v==7:
        print('{X[0]}{ops[0]}{X[1]}{ops[1]}{X[2]}{ops[2]}{X[3]}=7'.format(X=X, ops=ops))
        exit()

Measured memory_bytes: 3060
from itertools import combinations
from math import hypot

N, *XY = map(int, open(0).read().split())

print("{:.9f}".format(sum(hypot(ax - bx, ay - by) for (ax, ay), (bx, by) in combinations(zip(*[iter(XY)] * 2), 2)) * 2 / N))

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

typedef long long ll;

const int MAXN = 3002;

ll dp[MAXN][MAXN];
bool vis[MAXN][MAXN];
int A[MAXN],N;

ll solve(int i,int j){

	if(vis[i][j]) return dp[i][j];

	vis[i][j] = 1;

	if(i == j) return dp[i][j] = A[i];

	return dp[i][j] = max(A[i] - solve(i+1,j), A[j] - solve(i,j-1));

}

int main(){

	cin >> N;
	for(int i = 1;i<=N;i++){
		cin >> A[i];
	} 

	cout << solve(1,N) << endl;

	return 0;

}

Measured memory_bytes: 58700
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <queue>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
using namespace std;

typedef long long int ll;
#define MOD 1000000007
#define INF 1000000001

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

bool bfs(vector<vector<int>> g, vector<int> &dist, int sv)
{
	queue<int> q;
	q.push(sv);
	dist[sv]=0;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(auto v : g[now]){
			if(dist[v]!=-1) continue;
			dist[v] = dist[now]+1;
			q.push(v);
		}
	}
}

vector<vector<int>> g;
	
int rec(vector<int> &dp, int sv)
{
	if(dp[sv]!=-1){
//		cout << "sv: " << sv << "   dp : " << dp[sv] << endl;
		return dp[sv];
	}
	if(g[sv].size()==0) return dp[sv]=0;

	int ret=-1;
	rep(v,g[sv].size()){
		ret = max(ret,rec(dp,g[sv][v])+1);
	}
	return dp[sv]=ret;

}

int main(void) {
	int n,m; cin >> n >> m;
	g.assign(n,vector<int>());
	vector<int> dp(n,-1);
	rep(i,m){
		int x,y; cin >> x >> y;
		x--;y--;
		g[x].push_back(y);
	}
	int ans = -1;
	rep(i,n) ans = max(ans,rec(dp,i));
	out(ans);
}




Measured memory_bytes: 8192
#pragma GCC optimize(3)
#include <bits/stdc++.h>
#include <cstring>
using namespace std;
char a[11];
int main()
{
    gets(a);
    if(a[0]=='Y'&&a[1]=='A'&&a[2]=='K'&&a[3]=='I') printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n, k;
vector<int> a,s;
map<int,int> m;
signed main() {

    cin >> n >> k;
    a.resize(n);
    s.bash(0);
    for(auto&&i:a){
        cin>> i ;
        s.bash((s[s.size()-1] + i)%k);
    }
    ll cnt = 0;
    for(int i = 0; i <= n; i++) {
        if(i >= k) {
            int p = i - k;
            m[(s[p] + k - p%k)%k]--;
        }
        int v = (s[i] + k - i % k) % k;
        cnt += m[v];
        m[v]++;    
    }

    cout << cnt << endl;
    
    return 0;
}



Measured memory_bytes: 11252
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
#include<queue>
#include<map>

using namespace std;


int main(){
    int min;
    int idx;
    int n;
    int cnt = 0;
    cin >> n;

    vector<int> a(n);

    for(int i=0;i<n;i++) cin >> a[i];
    
    for(int i=0;i<n-1;i++){
        min = a[i];
        idx = i;
        for(int j=i+1;j<n;j++){
            if(min > a[j]){
                min = a[j];
                idx = j;
            }
        }
        if(idx != i) cnt++;
        swap(a[idx], a[i]);
    }

    for(int i=0;i<n;i++){
        if(i > 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
    cout << cnt << endl;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;

int main() {
    int d;
    cin >> d;
    cout << "Christmas";
    for (int i = 0; i < 25 - d; ++i) {
        cout << " Eve";
    }
    cout << "\n";
    return 0;
}


Measured memory_bytes: 256
N = int(input())
s = (0,0,0)
for _ in range(N):
    t, x, y = map(int, input().split())
    t0, x0, y0 = s
    if abs(x-x0) + abs(y-y0) <= t-t0 and (abs(x-x0) + abs(y-y0))%2==(t-t0)%2:
        s = (t,x,y)
        continue
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 74280
#include <stdio.h>
#include <queue>

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

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

int w, h;
char field[60][60];
bool visited[2][60][60];

class node {
public:
	int s, f, x, y;
	node(int _s, int _f, int _x, int _y) : s(_s), f(_f), x(_x), y(_y) {}
};

bool operator<(const node& l, const node& r) {
	return l.s>r.s;
}

int main() {
	for(;;) {
		scanf("%d%d", &w, &h);
		if(w==0) return 0;
		rep(y, h) rep(x, w) scanf(" %c", field[x]+y);
		rep(i, 2) rep(x, w) rep(y, h) visited[i][x][y] = false;
		priority_queue<node> q;
		rep(x, w) rep(y, h) if(field[x][y]=='S') {
			q.push(node(0, 0, x, y));
			q.push(node(0, 1, x, y));
		}
		int ms = -1;
		while(!q.empty()) {
			node v = q.top();
			q.pop();
			if(visited[v.f][v.x][v.y]) continue;
			visited[v.f][v.x][v.y] = true;
			rep(d, 9) {
				int x=v.x+(v.f?dx[d]:-dx[d]), y=v.y+dy[d];
				if(0<=x && x<w && 0<=y && y<h) {
					if(field[x][y]=='T') {
						ms = v.s;
						goto end;
					}
					else if(field[x][y]=='S') {
						q.push(node(v.s, (v.f+1)%2, x, y));
					}
					else if(field[x][y]!='X') {
						q.push(node(v.s+field[x][y]-'0', (v.f+1)%2, x, y));
					}
				}
			}
		}
	end:
		printf("%d\n", ms);
	}
}

Measured memory_bytes: 928
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>
//#include "MyLib.h"

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

vector<int> P;
bool isP[100005];

class comb
{
public:
	comb(long long int mod)
		:mod(mod)
	{}
	~comb()
	{}

	void init(int n)
	{
		fact.resize(n);
		fact[0] = 1;
		for (int i = 1; i < n; ++i)
		{
			//! 階乗
			fact[i] = fact[i - 1] * i;
			fact[i] %= mod;
		}

		//! 階乗の逆元
		revFact.resize(n);
		revFact[n - 1] = powmod(fact[n - 1], mod - 2);
		for (int i = n - 2; i >= 0; --i)
		{
			revFact[i] = revFact[i + 1] * (i + 1);
			revFact[i] %= mod;
		}
	}

	long long int get(int a, int b)
	{
		return (((fact[a] * revFact[b]) % mod)*revFact[a - b]) % mod;
	}

private:

	long long int powmod(long long int a, long long int p)
	{
		long long int ans = 1;
		long long int mul = a;
		for (; p > 0; p >>= 1, mul = (mul*mul) % mod)
		{
			if ((p & 1) == 1) ans = (ans*mul) % mod;
		}
		return ans;
	}
	long long int mod;
	std::vector<long long int> fact;
	std::vector<long long int> revFact;
};

void init()
{
	isP[0] = isP[1] = false;
	FOR(i, 100000, 2)
	{
		if (isP[i])continue;
		P.push_back(i);
		isP[i] = true;
		for (int j = i; j < 100000; j += i)
		{
			isP[j] = true;
		}
	}
}

int main()
{
	int N, M;
	cin >> N >> M;
	comb c(MOD);
	c.init(100 + N);
	init();

	vector<pii> k;
	int i = 0;
	while (i < P.size())
	{
		if (M%P[i] != 0)
		{
			i++;
			continue;
		}

		if (k.size() == 0 || k[k.size() - 1].first != P[i])
		{
			k.push_back(pii(P[i], 1));
		}
		else
		{
			k[k.size() - 1].second++;
		}
		M /= P[i];
	}
	if (M != 1)
	{
		k.push_back(pii(M, 1));
	}

	ll ans = 1;
	REP(i, k.size())
	{
		ans *= c.get(k[i].second + N - 1, k[i].second);
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2048
import sys
def input():
    return sys.stdin.readline()[:-1]
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
keta=[0]*60
lis=[]
for i in range(n):
    tmp=[]
    for j in range(60):
        if (a[i]>>j)&1==1:
            keta[j]+=1
            tmp.append(j)
    lis.append(tmp)

s=sum(a)
ans=0
for i in range(n):
    s-=a[i]
    j=0

    for j in range(len(lis[i])):
        tmp2=lis[i][j]
        keta[tmp2]-=1
        ans+=(2**tmp2)*((n-(i+1)-keta[tmp2]*2))
    ans+=s
    ans%=mod
print(ans%mod)

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

int main() {
  
  int N,M;
  cin >> N >> M;
  
  vector<int> A(M);
  vector<int> B(M);
  
  for(int i=0; i<M; i++){
    cin >> A.at(i) >> B.at(i);
  }
    
  vector<int> road(N,0);
  for(int i=0; i<M; i++){
    road.at((A.at(i)-1))++;
    road.at((B.at(i)-1))++;
  }
    
  for(int i=0; i<N; i++){  
    cout << road.at(i) << endl;
  }
   
}


Measured memory_bytes: 3552
import java.util.Scanner;

public class Main {
    public static void main(String[] ars) {
        Scanner sc = new Scanner(System.in);
        int i = 0;
        while(++i <= 10000){
            int x = sc.nextInt();
            if(x == 0) break;
            else if(x > 0) System.out.println("Case " + i + ": " + x);
        }
    }
}



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

int main(int argc, const char * argv[]) {
    
    int n;
    long int answer;
    long int s=2;
    long int l=1;
    
    cin >> n;
    
    if(n==1){
        cout << 1 << endl;
    }
    else{
        
        for(int i=2;i<=n;i++){
            answer=s+l;
            s=l;
            l=answer;
        }
        cout << answer << endl;
        
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
static const int MAX_V = 100000;

//Graph Element
struct E {
	E(int t, int f) {
		to = t;
		from = f;
	}
	E(int t, int f, int c) {
		to = t;
		from = f;
		cost = c;
	}
	int to;
	int from;
	int cost;
	bool visited;
	bool use;
};
struct V {
	vector<E*> edge;
	bool visited;
};
V G[MAX_V];
/////////////////////////////////////////////

//dfs
int ans = 0;
int VS, ES;
void dfs(int n) {
	rep(i, 0, G[n].edge.size()) {
		if (G[n].edge[i]->use && !G[G[n].edge[i]->to].visited) {
			G[G[n].edge[i]->to].visited = true;
			dfs(G[n].edge[i]->to);
		}
	}
}

void dfs_stack_lib(int n) {
	rep(i, 0, G[n].edge.size()) {
		if (G[n].edge[i]->use && !G[G[n].edge[i]->to].visited) {
			G[G[n].edge[i]->to].visited = true;
			dfs(G[n].edge[i]->to);
		}
	}
}

void dfs_stack_array(int n) {
	rep(i, 0, G[n].edge.size()) {
		if (G[n].edge[i]->use && !G[G[n].edge[i]->to].visited) {
			G[G[n].edge[i]->to].visited = true;
			dfs(G[n].edge[i]->to);
		}
	}
}
//BFS by array
//void bfs_queue_array(int n) {
//	int q[1000] = {};
//	int s = 0, e = 0;
//	q[e++] = n;
//	int c = 0;
//
//	while (s < e) {
//		c = q[s++];
//		G[c].visited = true;
//
//		rep(i, 0, G[c].edge.size()) {
//			if (G[c].edge[i]->use && !G[G[c].edge[i]->to].visited) {
//				q[e++] = G[c].edge[i]->to;
//			}
//		}
//	}
//}

//BFS by queue
void bfs_queue_lib(int n) {
	queue<int> q;
	q.push(n);

	while (!q.empty()) {
		int c = q.front(); q.pop();
		G[c].visited = true;

		rep(i, 0, G[c].edge.size()) {
			if (G[c].edge[i]->use && !G[G[c].edge[i]->to].visited) {
				q.push(G[c].edge[i]->to);
			}
		}
	}
}
int main() {
	cin >> VS >> ES;

	rep(i, 0, ES)
	{
		int s, t; cin >> s >> t;
		G[s].edge.push_back(new E(t, s));
		G[t].edge.push_back(new E(s, t));
	}

	///////////////////////////////////////////////////////////
	//DFS
	//Edge all false
	repe(i, 1, VS) rep(j, 0, G[i].edge.size()) {
		//Edge all visited false;
		repe(k, 1, VS) rep(l, 0, G[k].edge.size()) G[k].edge[l]->use = true;
		repe(k, 1, VS) G[k].visited = false;

		G[i].edge[j]->use = false;

		//DFS
		G[1].visited = true;
		//dfs(1);
		bfs_queue_lib(1);

		bool ok = true;
		repe(k, 1, VS)  ok &= G[k].visited;
		if (!ok)ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3328
import java.util.*;

class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	String[] foo = sc.nextLine().split("");
      	int hoge[] = new int[4];
      	for(int i = 0; i < 4; i++) {
      		hoge[i] = Integer.parseInt(foo[i]);
      	}
      	int temp = -1;
      	String str = "Good";
      	for(int i = 0; i < 4; i++){
      		int nabe = hoge[i];
        	if(temp==nabe){
            	str = "Bad";
              	break;
            }
          	temp = nabe;
        }
      
      	System.out.println(str);
    }
}

Measured memory_bytes: 21716
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define MEM(a,b) memset(a,b,sizeof(a))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int unko[364364];
int main() {
	int n;
	string s;
	
	cin >> n >> s;
	int tmp = 0;
	REP(i, n) {
		unko[i] = tmp;
		if (s[i] == 'W')tmp++;
	}
	unko[n] = tmp;
	int min = 810931;
	REP(i,n){
		int cnt = unko[i];
		cnt += (n - (i + 1)) - (unko[n] - unko[i + 1]);
		if (cnt < min)min = cnt;
	}
	cout << min << endl;
}

Measured memory_bytes: 1796
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int c = 0;
		for (int i = 0; i < N; i++) {
			int A = sc.nextInt();
			if (A % 2 == 1) {
				c++;
			}
		}
		if (c % 2 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 32320
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();
    vector<string> ans;
    rep(i, n) {
        string res = s;
        bool ok = false;
        rep(j, m) {
            if(i+j >= n) break;
            if(s[i+j]==t[j]);
            else if(s[i+j]=='?') {
                res[i+j] = t[j];
            }else break;
            if(j==m-1) ok = true;
        }
        if(ok){
            rep(i, n) if(res[i]=='?') res[i] = 'a';
            ans.push_back(res);
        }
    }
    sort(ans.begin(), ans.end());
    if(ans.size() > 0) {
        cout << ans[0];
    }
    else
    cout << "UNRESTORABLE";
}


Measured memory_bytes: 256
//#define LOCAL

#include <fstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <cstring>

#define int long long
//typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); i++)

#define MOD 1000000007

using namespace std;

signed main()
{
#ifdef LOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif

    int X, Y;
    cin >> X >> Y;
    if (abs(X - Y) <= 1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    int count = 0;

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

      double sqrt = Math.sqrt((Math.pow(x, 2) + Math.pow(y, 2)));
      if (sqrt <= d) {
        count++;
      }
    }

    System.out.println(count);
  }
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != t[i]) ans++;
  }

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

Measured memory_bytes: 3916
X, Y = map(int, input().split())

mod = 10 ** 9 + 7


def choose(n, r):
    x = 1
    y = 1
    for i in range(min(r, n - r)):
        x = x * (n - i) % mod
        y = y * (i + 1) % mod
    y = pow(y, mod - 2, mod)
    return (x * y) % mod


ans = 0

if (X + Y) % 3 == 0:
    n = (2 * Y - X) // 3
    m = (2 * X - Y) // 3
    if min(n, m) >= 0:
        ans = choose(n + m, n)


print(ans)


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


void solve(long long N, long long M, std::vector<long long> s, std::vector<long long> c){
    vector<int> ans(N,-1);
    for(int i= 1;i<=N;i++){
        for(int j=0;j<M;j++){
            if(s[j] == 1 && c[j] == 0&& N != 1){
                cout << -1 << endl;
                return;
            }
            if(s[j] == i){
                if(ans[N-i] ==-1){
                    ans[N-i] = c[j];
                }else if(ans[N-i]!= c[j]){
                    cout << -1 << endl;
                    return;
                }
            }
        }
    }
    for(int i=0;i<N;i++){
        if(ans[i] == -1){
            if(N-i-1 == 0 && N != 1){
                ans[i] =1;
            }else{
            ans[i]=0;
            }
        }
    }
    int out =0;
    for(int i=0;i<N;i++){
        cerr << ans[N-i-1] << endl;
        out += ans[N-i-1] *pow(10,N-i-1);
    }
    cout << out<< endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> s(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, M, std::move(s), std::move(c));
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)){
			int n = sc.nextInt();
			Set<Long> treeSet = new TreeSet<Long>();
			for (int i=0; i<n; i++) {
				 treeSet.add(sc.nextLong());
			}
			Long[] array = new Long[treeSet.size()];
			treeSet.toArray(array);
			for (int i=0; i<array.length - 1; i++) System.out.print(array[i] + " ");
			System.out.println(array[array.length - 1]);
		}
	}
}


Measured memory_bytes: 78056
abcd = input().split()

a = int(abcd[0])
b = int(abcd[1])

c = int(abcd[2])
d = int(abcd[3])


def zero(x,y):
  if x <= 0:
    return("Yes")
  elif y <= 0:
    return("No")

for i in range(100):
  c = c - b
  if c <= 0:
    print("Yes")
    break
  a = a - d
  if a <= 0:
    print("No")
    break

Measured memory_bytes: 9204
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int K, S;
	cin >> K >> S;

	auto count = 0;
	for (auto i = 0; i <= K; ++i)
	{
		for (auto j = 0; j <= K; ++j)
		{
			if (i + j > S || S - i - j > K)
			{
				continue;
			}

			++count;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256