akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <queue>
#include <iomanip>
typedef long long LL;
using namespace std;
typedef pair<int, int> Pii;
typedef pair<LL, LL> PLL;
const int maxn = 1E2 + 5;
int n, m, x[maxn], y[maxn], X, Y;
bool cmp(int a, int b){
	return a > b;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> m >> X >> Y;
	bool ok;
	for(int i = 1; i <= n; i++){
		cin >> x[i];
	}
	sort(x + 1, x + n + 1, cmp);
	for(int i = 1; i <= m; i++){
		cin >> y[i];
	}
	sort(y + 1, y + m + 1);
	if(x[1] >= y[1]) ok = false;
	else {
		if(X >= y[1] || Y <= x[1]) ok = false;
		else ok = true;
	}
	if(ok) cout << "No War" << endl;
	else cout << "War" << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = [int(t)for t in input().split()]
    ans = [0]*n
    for i in range(n-1)[::-1]:
        ans[a[i]] += 1

    for ans_i in ans[1:]:
        print(ans_i)
    print(0)


if __name__ == "__main__":
    main()

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

int main() {
    int n, H, W;
    scanf("%d %d %d", &n, &H, &W);

    int ans = 0;
    for (int i = 0, h, w; i < n; i++) {
        scanf("%d %d", &h, &w);
        ans += std::min(h / H, w / W);
    }

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

Measured memory_bytes: 128
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	int n, m, red = 0, x, y, cnt = 0;
	cin >> n >> m;
	vector<int>ball(n, 1);
	vector<bool>visit(n, false);
	visit[red] = true;

	rep(i, m) {
		cin >> x >> y;
		x--, y--;
		if (visit[x]) {
			visit[y] = true;
		}
		ball[x]--; ball[y]++;
		if (visit[x] && ball[x] == 0)visit[x] = false;
	}
	rep(i, n) {
		if (visit[i] && 1 <= ball[i])cnt++;
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3680
package main

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

const mod = 1000000007
const facNum = 2000005
const INF = 2 << 31

func main() {
	sc := newScanner(os.Stdin)
	K, S := sc.i(), sc.s()
	n := len(S)
	fac, ifac := factorial()
	ans := 0
	for i := 0; i <= K; i++ {
		now := Pow(26, K-i)
		now *= combination(i+n-1, n-1, fac, ifac)
		now %= mod
		now *= Pow(25, i)
		now %= mod
		ans += now
		ans %= mod
	}
	fmt.Println(ans)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

//------------------------------

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


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

int main(void)
{
  int i, j, k;
  double tmp;
  double a[2][3];
  double x[2];

  memset(a,0,sizeof(a));
  memset(x,0,sizeof(x));

  while(1){
	for (i = 0;i < 2;i++){
	  for (j = 0;j < 3;j++){
		if (scanf("%lf", &a[i][j]) == EOF){
		  return 0;   
		}
	  }
	}

	for (i = 0;i < 2;i++){
	  if (a[i][i] == 0){
		for (j = i + 1;j < 2;j++){
		  if (a[j][i] != 0){
			for (k = 0;k < 2;k++){
			  tmp = a[i][k];
			  a[i][k] = a[j][k];
			  a[j][k] = tmp;
			}
			break;
		  }
		}
	  }
	}

	for (i = 0;i < 2;i++){
	  for (j = i + 1;j < 2;j++){
		tmp = a[j][i] / a[i][i];
		for (k = i;k < 3;k++){
		  a[j][k] -= a[i][k] * tmp;
		}
	  }
	}

	for (i = 2 - 1;i >= 0;i--){
	  for (j = 2;j > i + 1;j--){
		a[i][j-1] = a[i][j] - (x[j-1] * a[i][j-1]);
	  }
	  x[i] = a[i][i+1] / a[i][i];
	}

	for (i = 0;i < 2;i++){
	  if (i == 0){
		 printf("%.3lf ", x[i]);
	  }
	  else if (i == 1){
		printf("%.3lf", x[i]);
	  }
	}
	printf("\n");
	memset(a,0,sizeof(a));
	memset(x,0,sizeof(x));
  }

  return 0;
}

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

using namespace std;
int main()
{
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  m1 += h1 * 60;
  m2 += h2 * 60;
  cout << m2 - m1 - k << endl;
  
}


Measured memory_bytes: 3592
#include<iostream>
#include<bits/stdc++.h>
#include<climits>
#include<math.h>

#define forn(x,n,s) for(int i = x; i < n; i += s )
#define forr(x,n,s) for(int i = x; i>=n; i -= s)
#define PI 3.14159265358979323846264338327950L
#define MOD 1e9+7

using namespace std;

void go(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  #ifndef ONLINE_JUDGE
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
  #endif
} 

int main(){
    go(); 

    // code here
    int n;cin>>n;
    set<string> st;
    forn(0,n,1){
        string inp;cin>>inp;
        st.insert(inp);
    }
    cout<<st.size();
} 



Measured memory_bytes: 19228
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>A(N);
  
  for(int j=0;j<N;j++){
  int x;
    cin>>x;
    int sum=0;
    for(int i=0; ;i++){
    if(x%2==0){
     x/=2; sum++;
    }else
      break;
      if(sum==2) break;
    }A.at(j)=sum;
  
 }int a1=0;
  int a2=0;
  for(int i=0;i<N;i++){
   if(A.at(i)==1)
     a1++;
    if(A.at(i)==2)
      a2++;
  }if(1<=a1){if(2*a2+a1<N)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;}
  else{
  if(2*a2+1<N)
    cout<<"No"<<endl;
    else
      cout<<"Yes"<<endl;
  }
    
  return 0;
}

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

#define ll long long 
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()

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

	int a; cin >> a;
	cout << a + a * a + a * a * a;
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

vector<vector<pair<int,int> > >adj;
int dis[2][100005];
int ans[2][100004];
const int mod=1e9+7;

void dikstra(int ver,int x)
{
    dis[x][ver]=0;
    priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >qq;
    qq.push({0,ver});
    ans[x][ver]=1;
    while(!qq.empty())
    {
        pair<int,int>p=qq.top();
        qq.pop();
        if(dis[x][p.second]<p.first)
            continue;
        for(auto i:adj[p.second])
        {
            if(dis[x][i.first]>p.first+i.second)
            {
                dis[x][i.first]=p.first+i.second;
                qq.push({dis[x][i.first],i.first});
                ans[x][i.first]=ans[x][p.second];
            }
            else if(dis[x][i.first]==p.first+i.second)
            {
                ans[x][i.first]+=ans[x][p.second];
                ans[x][i.first]%=mod;
            }
        }
    }
}

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    int s,t;
    cin>>s>>t;
    int x,y,z;
    vector<pair<pair<int,int> ,int> >pp;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y>>z;
        pp.push_back({{x,y},z});
        adj[x].push_back({y,z});
        adj[y].push_back({x,z});
    }

    fill_n(&dis[0][0],2*100005,1e17);
    dikstra(s,0);
    dikstra(t,1);
    int res=0;
    for(int i=1;i<=n;i++)
    {
        if(dis[0][i]+dis[1][i]==dis[0][t])
        {
            if(dis[0][i]==dis[1][i])
            {
                int xx=(ans[0][i]*ans[1][i])%mod;
                res+=(xx*xx)%mod;
                res%=mod;
            }
        }
    }

    for(auto i:pp)
    {
        x=i.first.first;
        y=i.first.second;
        int mn=min(dis[0][x],dis[1][y]);
        int mx=max(dis[0][x],dis[1][y]);
        if(dis[0][x]+dis[1][y]+i.second==dis[0][t])
        {
            if(mn+i.second>mx)
            {
                int xx=(ans[0][x]*ans[1][y])%mod;
                res+=(xx*xx)%mod;
                res%=mod;
            }
        }
        x=i.first.second;
        y=i.first.first;
        mn=min(dis[0][x],dis[1][y]);
        mx=max(dis[0][x],dis[1][y]);
        if(dis[0][x]+dis[1][y]+i.second==dis[0][t])
        {
            if(mn+i.second>mx)
            {
                int xx=(ans[0][x]*ans[1][y])%mod;
                res+=(xx*xx)%mod;
                res%=mod;
            }
        }        
    }

    int tot=(ans[0][t]*ans[1][s])%mod;
    tot+=mod-res;
    tot%=mod;
    cout<<tot;

} 


Measured memory_bytes: 25124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
const int MOD = 1000000007;

int main() {
    int n; cin >> n;
    set<int> vec;
    for(int i = 0;i < n;i++){
        int x; cin >> x;
        if(vec.count(x)){
            vec.erase(x);
        }else{
            vec.insert(x);
        }
    }
    cout << vec.size();
}




Measured memory_bytes: 4864
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,r,p,s;
    cin >> n;
    vector<int>v(n);
    for (int i=0;i<n;i++) cin>>v[i];
    sort(v.begin(),v.end());
    r=p=s=0;
    for(int i=0;i<n;i++){
        if(v[i]!=r){
            if(p>=r) s+=p-r;
            else s+=p;
            r=v[i];
            p=1;
        }else p++;
    }
    if(p>=r) s+=p-r;
    else s+=p;
    cout <<s<< endl;
    return 0;
}


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

int main(){

  string s,t,u;
  int a,b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if (u == s) a--;
  else b--;

  cout << a << " " << b;

  return 0;
}

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

int main()
{
    string s, t;
    cin >> s >> t;

    reverse(t.begin(), t.end());
    string a;
    a = t[0];
    s = s + a;
    reverse(t.begin(), t.end());
    if (s == t) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3640
import itertools as itr

A=list(map(int,input()))
b=list(itr.product(range(2),repeat=3))

for i in b:
    i=['+' if j==1 else '-' for j in i]
    ans=A[0]

    for j in range(3):
        if i[j]=='+':
            ans+=A[j+1]
        else:
            ans-=A[j+1]

    if ans==7:
        C=[]
        for j in range(3):
            C.append(A[j])
            C.append(i[j])
        C.append(A[3])
        C.append('=7')
        print(''.join(map(str,C)))
        exit(0)   

print(-1)

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

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

    vector<int> R(N);
    for (int i = 0; i < N; i++)
    {
        cin >> R.at(i);
    }
    
    int count = 0;

    for (int i = 0; i < N-1; i++) // i は入れ替える最後の要素 
    {
        for (int j = N-1; j > i; j--)
        {
            if (R.at(j) < R.at(j-1))
            {
                int temp = R.at(j);
                R.at(j) = R.at(j-1);
                R.at(j-1) = temp;
                count++;
            }
            
        }
        
    }
    
    for (int i = 0; i < N; i++)
    {
        cout << R.at(i);
        if (i != N-1)
        {
            cout << ' ';
        }
        
    }
    cout << endl;
    cout << count << endl;
}


Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();
		int s = 0;
		int s1 = a * b;
		int s2 = c * d;
		if(s1 >= s2) {
			s = s1;
		} else {
			s = s2;
		}
		System.out.println(s);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int main(void){
  int n;
  cin >> n;
  vector<double> p(n);
  REP(i, n) cin >> p[i];

  vector<vector<double>> dp(n+1, vector<double>(n+1, 0));
  dp[0][0] = 1;
  REP(i, n){
    REP(j, n){
      if(j > i) break;
      dp[i+1][j] += dp[i][j] * (1-p[i]);
      dp[i+1][j+1] += dp[i][j] * p[i];
    }
  }

  double ans = 0;
  FOR(i, (n+1)/2, n+1){
    ans += dp[n][i];
  }

  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 70784
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Wed Mar 28 21:33:25 2018
//
package main

import (
	"fmt"
)

var S string

func main() {
	fmt.Scan(&S)
	var n, w, s, e bool

	for i := range S {
		if S[i] == 'N' {
			n = true
		} else if S[i] == 'W' {
			w = true
		} else if S[i] == 'S' {
			s = true
		} else {
			e = true
		}
	}
	if n == s && w == e {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#転置はすごい！！！
h,w = gets.strip.split.map(&:to_i)
ary = []
h.times do
  a = gets.strip.to_s
  b = a.split("").map(&:to_s)
  unless b.all?(".")
    ary << b
  end
end
arys = ary.transpose
arys.each do |x|
  if x.all?(".")
    arys.delete(x)
  end
end
newary = arys.transpose
newary.each do |x|
  puts x.join("")
end

Measured memory_bytes: 14492
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_macros)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        ::std::cmp::min($x, max!($($y),+))
    };
}

const MOD: usize = 1_000_000_007;
const MAX: usize = 510_000;
fn com_init(fac: &mut [usize], finv: &mut [usize], inv: &mut [usize]) {
    fac[0] = 1;
    fac[1] = 1;
    finv[0] = 1;
    finv[1] = 1;
    inv[1] = 1;
    for i in 2..MAX {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

fn bin_coef(n: usize, k: usize, fac: &mut [usize], finv: &mut [usize], inv: &mut [usize]) -> usize {
    if k > n/2 {
        bin_coef(n-k, k, fac, finv, inv)
    } else {
        fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
    }
}


use std::cmp;
use std::collections::{HashSet, BinaryHeap, VecDeque, HashMap};
use std::iter::FromIterator;
fn main() {
    input!{
        N: usize,
        kodo: [(usize, usize, usize); N],
    }

    let max = kodo.iter().fold((0, 0, 0), 
    |acc, x| ( x.0+max!(acc.1, acc.2), x.1+max!(acc.2, acc.0), x.2+max!(acc.0, acc.1) ));
    println!("{}", max!(max.0, max.1, max.2));
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

const int maxV=314514;
struct edge{int end;int cost;};
typedef pair<int,int> P;
int V;
vector<int> d;
vector<edge> G[maxV];

void dijkstra(int s){
    priority_queue<P,vector<P>,greater<P>> que;
    for(int i=0;i<maxV;i++){d.push_back(INF);}
    d[s]=0;
    que.push(P(0,s));
    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v]<p.first)continue;
        for(int i=0;i<G[v].size();i++){
            edge e = G[v][i];
            if(d[e.end]>d[v]+e.cost){
                d[e.end] = d[v]+e.cost;
                que.push(P(d[e.end],e.end));
            }
        }
    }
}


signed main(void){
    int N,M;
    int u[114514],v[114514];
    int S,T;
    cin >> N >> M;
    REP(i,M){
        cin >> u[i] >> v[i];
        u[i]--;v[i]--;
    }
    cin >> S >> T;
    S--;T--;
    edge h;
    REP(i,M){
        h.cost=1;
        h.end=v[i]+N;
        G[u[i]].push_back(h);
        h.end=v[i]+2*N;
        G[u[i]+N].push_back(h);
        h.end=v[i];
        G[u[i]+2*N].push_back(h);
    }
    dijkstra(S);
    if(d[T]!=INF){
        cout << d[T]/3 << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}



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

int main() {
  	vector<long> a(5);
  	int n;
  	string t;
  	cin >> n;
  	for(int i = 0; i < n; i++) {
    	cin >> t;
      	if(t[0] == 'M')
          	a[0]++;
      	else if(t[0] == 'A')
          	a[1]++;
      	else if(t[0] == 'R')
          	a[2]++;
      	else if(t[0] == 'C')
          	a[3]++;
      	else if(t[0] == 'H')
          	a[4]++;
    }
  	long count;
  	count = a[0]*a[1]*a[2] + a[0]*a[1]*a[3] + a[0]*a[1]*a[4] + a[0]*a[2]*a[3]
       + a[0]*a[2]*a[4] + a[0]*a[3]*a[4] + a[1]*a[2]*a[3] + a[1]*a[2]*a[4]
       + a[1]*a[3]*a[4] + a[2]*a[3]*a[4];
  	cout << count << endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

addans=0

for i in range(n-1) :
  if a[i]+1 == a[i+1] :
    addans += c[a[i]-1]
print(sum(b)+addans)

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

using namespace std;

const int grid_num = 3;

int main() {
  vector<vector<int>> grid(grid_num + 1, vector<int>(grid_num + 1, -1));

  for(int i = 1; i <= grid_num; i++) {
    for(int j = 1; j <= grid_num; j++) {
      cin >> grid[i][j];
    }
  }

  // a1 - a2
  bool can = true;
  if(grid[1][1] - grid[2][1] != grid[1][2] - grid[2][2] ||
    grid[1][2] - grid[2][2] != grid[1][3] - grid[2][3]) {
    can = false;
  }
  // a2 - a3
  if(grid[2][1] - grid[3][1] != grid[2][2] - grid[3][2] ||
    grid[2][2] - grid[3][2] != grid[2][3] - grid[3][3]) {
    can = false;
  }

  // b1 - b2
  if(grid[1][1] - grid[1][2] != grid[2][1] - grid[2][2] ||
    grid[2][1] - grid[2][2] != grid[3][1] - grid[3][2]) {
    can = false;
  }
  // b2 - b3
  if(grid[1][2] - grid[1][3] != grid[2][2] - grid[2][3] ||
    grid[2][2] - grid[2][3] != grid[3][2] - grid[3][3]) {
    can = false;
  }


  if(can) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    Vi colors(n-1);
    V<V<Pii>> v(n+1);
    REP(i, n-1) {
        int a, b;
        cin >> a >> b;
        v[a].push_back({b, i});
        v[b].push_back({a, i});
    }

    queue<pair<Pii, int>> q;
    q.push({{1, -1}, 1e9});
    int maxi = -1;
    while (!q.empty()) {
        int node = q.front().first.first;
        int back = q.front().first.second;
        int color = q.front().second;
        q.pop();

        int cnt = 0;
        REP(i, v[node].size()) {
            int node2 = v[node][i].first;
            if (node2 == back) continue;
            int c = cnt >= color ? cnt+1 : cnt;
            cnt++;
            colors[v[node][i].second] = c;
            if (maxi < c) {
                maxi = c;
            }
            q.push({{node2, node}, c});
        }
    }

    std::cout << maxi+1 << '\n';
    FOR(i, colors) {
        std::cout << *i + 1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 7040
N = int(input())
d_lis = list(map(int, input().split()))
d_lis.sort()

ARC_min = d_lis[int(N/2)]
ABC_max = d_lis[int(N/2)-1]

if ( ABC_max == ARC_min ):
	print(0)
else:
	print(ARC_min - ABC_max)


Measured memory_bytes: 14428
R, C, K = map(int, input().split())

items = [[0] * C for _ in range(R)]
for i in range(K):
    r, c, v = map(int, input().split())
    items[r-1][c-1] = v

dp = [[0] * 4 for _ in range(C)]

for i in range(R):
    dp2 = [[0] * 4 for _ in range(C)]
    for j in range(C):
        if j != 0:
            dp2[j] = dp2[j-1][:]

        dp2[j][0] = max(dp2[j][0], max(dp[j]))

        for k in range(3, 0, -1):
            dp2[j][k] = max(dp2[j][k], dp2[j][k-1] + items[i][j])

    dp = dp2

print(max(dp[-1]))


Measured memory_bytes: 225080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef pair<ll, ll> P;

int main(){
    string s, ans="Yes";
        cin >> s;
    for(int i=0; i<s.size(); i++){
        if(i%2==0 && s[i]!='L') continue;
        if(i%2==1 && s[i]!='R') continue;
        ans = "No";
        break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MAX_N 51
using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    vector<ll> a(n+2,0);
    vector<ll> b(n+1,0);
    for(int i =1; i<= n+1;i++) cin>>a[i];
    for(int i =1; i<=n;i++) cin>>b[i];

    ll sum = 0;

    for(int i =1; i<=n; i++){
        for(int j = i;(j-i) < 2 ;j++){
            if(b[i] >=a[j]){
                sum += a[j];
                b[i] -= a[j];
                a[j] = 0;
            }else{
                sum += b[i];
                a[j] -= b[i];
                b[i] = 0;
            }
        }
    }
    cout<< sum <<endl;
    return 0;
}


Measured memory_bytes: 1792
import std.stdio;
import std.string;
import std.conv;
import std.array;
import std.math;

void main()
{
    auto buf = readln.split;
    int N = buf[0].to!int;
    int K = buf[1].to!int;
    int[] h = readln.split.to!(int[]);

    int[] cost = new int[N];
    cost[0] = 0;
    foreach (i; 1..N){
        int min_c = cost[i - 1] + abs(h[i] - h[i - 1]);
        foreach (j; 2..(K+1)){
            if (i - j < 0) break;

            int c = cost[i - j] + abs(h[i] - h[i - j]);
            if (c < min_c) min_c = c;
        }

        cost[i] = min_c;
    }

    writeln(cost[$ - 1]);
}



Measured memory_bytes: 4388
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second

signed main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int l,r,d;
	cin >> l >> r >> d;
	cout << r/d - (l-1)/d;


	
	

	return 0;
}

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

bool solve(int r,int c){
	if(r%2==1 && c%2 ==1){
		return false;
	}else{
		return true;
	}
}


int main(){
	int r,c;
	
	while(cin>>r>>c,r!=0||c!=0){
		if(solve(r,c)){
			cout<<"yes"<<endl;
		}else{
			cout<<"no"<<endl;
		}
	}
}

Measured memory_bytes: 1152
x =int(input())
n = 2*10**5

is_prime = [True]*(n+1)
is_prime[0] = False

for i in range(2, n+1):
    if is_prime[i-1]:
        j = 2 * i
        while j <= n:
            is_prime[j-1] = False
            j += i

for i in range(x-1,n):
    if is_prime[i]==True:
        print(i+1)
        break

Measured memory_bytes: 40816
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int l = scan.nextInt();
		int[][] A = new int[n][m];
		int[][] B = new int[m][l];
		long[][] AB = new long[n][l];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				A[i][j] = scan.nextInt();
			}
		}
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < l; j++) {
				B[i][j] = scan.nextInt();
			}
		}
		long lonSum = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				for (int k = 0; k < m; k++) {
					lonSum += A[i][k] * B[k][j];
				}
				AB[i][j] = lonSum;
				lonSum = 0;
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < l; j++) {
				if(j == 0){
					System.out.print(AB[i][j]);
				}else{
					System.out.print(" " + AB[i][j]);
				}

			}
			System.out.println();
		}
		scan.close();
	}
}

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

int main() {
    int N; cin >> N;
    vector<int> A(N), B(N);
    vector<int> C(N);
    ll totalB = 0;
    rep(i, N){
        cin >> A[i] >> B[i];
        C[i] = A[i] + B[i];
        totalB += B[i];
    }

    sort(C.begin(), C.end());
    int n = (N+1) / 2;
    ll totalA = 0;
    rep(i, n){
        totalA += C[N-1-i*2];
    }

    cout << totalA - totalB << endl;

    return 0;
}

Measured memory_bytes: 4232
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)
int n;
vector<vector<pair<int, int>>> G;
vector<int> res;

void dfs(int node, int p, int c)
{
    res[node] = c;
    for (auto to : G[node])
    {
        if (to.first == p)
            continue;
        if (to.second & 1)
        {
            dfs(to.first, node, 1 - c);
        }
        else
        {
            dfs(to.first, node, c);
        }
    }
}
int main()
{
    cin >> n;
    res.resize(n, 0);
    G.resize(n,vector<pair<int,int>>());
    repi(i, n - 1, 0)
    {
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        G[u].push_back({v, w});
        G[v].push_back({u, w});
    }
    dfs(0, -1, 0);
    for (int e : res)
        cout << e << endl;
    return 0;
}

Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N,L; cin >> N >> L;
	int min = L;
	for(int i=2;i<N+1;i++){
		if(abs(min) > abs(L+i-1)) min = L+i-1;
	}
	int sum = 0;
	for(int i=1;i<N+1;i++){
		sum += L+i-1;
	}
	cout << sum - min << endl;
	return 0;
}

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

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

using namespace std;

int main() {
	int N;
	long long K;
	int Q;
	cin >> N >> K >> Q;
	vector<int> A(N, K-Q);

	rep(i, Q) {
		int num;
		cin >> num;
		A[num - 1]++;
	}
	rep(i, N) {
		if (A[i] > 0)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}



Measured memory_bytes: 1024
n,m = map(int, input().split( ))
sw = [0 for _ in range(m)]#でんきゅがつながってるスイッチ
for i in range(m):
    s = list(map(int, input().split( )))
    s = [si-1 for si in s[1:]]
    bt = 0
    for sj in s:#電球
        bt += 1<<sj
    sw[i] = bt
    
p = list(map(int, input().split( )))

#スイッチ
bit = 1<<n
ans = 0
for i in range(bit):#スイッチつけ方
    flag = True
    for j in range(m):#電球
        cnt = 0
        for k in range(n):#スイッチチェック
            cnt += (i&sw[j])>>k
        if cnt%2!=p[j]:
            flag = False
    if flag:
        ans += 1
print(ans)
        

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

int main()
{
	string s; cin >> s;
	for (int i=0; i<s.size(); i++)
		if (s[i] == '7')
		{
			cout<<"Yes\n";
			return 0;
		}
	cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3624
s = input()
n = len(s)+1
a = [-1]*n
flag = False
for i in range(n-1):
    if s[i] == "<":
        if not flag: a[i] = 0
        a[i+1] = a[i]+1
        flag = True
    else: flag = False
flag = False
for i in range(n-1):
    j = n-2-i
    if s[j] == ">":
        if not flag: a[j+1] = 0
        a[j] = max(a[j], a[j+1]+1)
        flag = True
    else: flag = False
print(sum(a))


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

using namespace std;

const int DEFAULT = 0;

struct SegmentTree {
    int n;
    vector<int> heap;
    
    SegmentTree(int n): n(n) {
        heap.assign(4 * n, DEFAULT);
    }
    
    void update(int nodeId, int l, int r, int ql, int qr, int v) {
        if (qr < l || ql > r) {
            return;
        }
        else if (ql <= l && r <= qr) {
            heap[nodeId] += v;
        }
        else {
            int m = l + (r - l)/2;
            update(nodeId * 2, l, m, ql, qr, v);
            update(nodeId * 2 + 1, m + 1, r, ql, qr, v);
        }
    }
    
    int query(int nodeId, int l, int r, int q) {
        if (q < l || q > r) {
            return 0;
        }
        
        if (l == r) {
            return heap[nodeId];
        }
        
        else {
            int result = heap[nodeId];
            int m = l + (r - l)/2;
            return result + query(nodeId * 2, l, m, q) + query(nodeId * 2 + 1, m + 1, r, q);
        }
    }
    
};

int main() {
    int n, q;
    cin >> n >> q;
    SegmentTree st(n);
    for (int i = 0; i < q; i++) {
        int cmd;
        cin >> cmd;
        if (cmd == 0) {
            int ql, qr, v;
            cin >> ql >> qr >> v;
            st.update(1, 1, n, ql, qr, v);
//            for (int i = 0; i < 4 * n; i++) {
//                cout << i << ":" << st.heap[i] << endl; 
//            }
        }
        else {
            int pos;
            cin >> pos;
            cout << st.query(1, 1, n, pos) << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 4412
#include <iostream>

using namespace std;

int main()
{
    // オリジナルの回答
    int num;
    cin >> num;
    int x = 0;

    num *= 100;
    bool b = false;
    for (int i = 0; i < 100; i++) {
        if ((num + i) % 108 == 0) {
            x = (num + i) / 108;
            b = true;
            break;
        }
    }

    if (b) {
        cout << x << endl;
    }
    else {
        cout << ":(" << endl;
    }

    return 0;
}


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

class prime{
	int sum;
	char p[MAX];
public:
	prime();
	int num(int n);
};

prime::prime(){
	p[0]=0;
	p[1]=0;
	p[2]=1;
	for(int i=3;i<MAX;i+=2)p[i]=1;
	for(int i=4;i<MAX;i+=2)p[i]=0;
	
	int c=3;
	while(c<1000){
		for(int i=c+2;i<MAX;i+=2){
			if(i%c==0)p[i]=0;
		}
		while(p[++c]==0);
	}
}

int prime::num(int n){
	sum=0;
	for(int i=0;i<=n;i++)sum+=p[i];
	return sum;
}

int main()
{
	int n;
	prime pr;
	while(cin >> n){
		cout << pr.num(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 1844
N = gets.to_i

res = N

0.upto(N) do |i|
  cc = 0
  t = i
  while t > 0
    cc += t % 6
    t /= 6
  end
  t = N - i
  while t > 0
    cc += t % 9
    t /= 9
  end

  if res > cc
    res = cc
  end
end

p res


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c,k;
	cin>>a>>b>>c>>k;
	if(a>=k){
		cout<<k;
		return 0;
	} 
	else if(a+b>=k){
		cout<<a;
		return 0;
	}
	else
	{
		int d=k-(a+b);
		cout<<a-d;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
int n,b[100],s=0;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(18);
	cin>>n;
	n--;
	for (int i=0;i<n;i++)
		cin>>b[i];
	s+=(b[0]+b[n-1]);
	for (int i=1;i<n;i++)
		s+=min(b[i],b[i-1]);
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
using namespace std;

int main(){
	int m,n;
	while(1){
	cin >> m;
	if(m==0)break;
	vector< pair<int,int> > star(m);
	vector< pair<int,int> > d1(m-1);
	for(int i=0; i<m; ++i){
		int x,y;
		cin >> x >> y;
		star[i].first=x;
		star[i].second=y;
		if(i!=0){
			d1[i-1].first=star[0].first-star[i].first;
			d1[i-1].second=star[0].second-star[i].second;
		}
	}
	cin >> n;
	vector< pair<int,int> > pic(n);
	for(int i=0; i<n; ++i){
		int x,y;
		cin >> x >> y;
		pic[i].first=x;
		pic[i].second=y;
	}
	for(int j=0; j<n; ++j){
		int cnt=0;
		bool ok=true;
		for(int i=0; i<m-1; ++i){
			for(int k=0; k<n; ++k){
				if( (d1[i].first==(pic[j].first-pic[k].first)) && (d1[i].second==(pic[j].second-pic[k].second))){
					++cnt;
					break;
				}
			}
			if(cnt==m-1){
				cout << pic[j].first-star[0].first << " " << pic[j].second-star[0].second << "\n";
				ok=true;
				break;
			} else{
				ok=false;
			}
		}
		if(ok) {
			break;
		}
	}
	}
	return 0;
}

Measured memory_bytes: 1200
x,y = (int(x) for x in input().split())

q = x // y
r = x % y
a = y
b = r
if (r == 0):
    print(x)
    exit()

else:
    while (r != 0):
        q = a // b
        r = a % b

        if (r == 0):
            print(b)
            break
        a = b
        b = r



Measured memory_bytes: 5604
using System;
class Program{
  
  static int w ,h;   
  static int wn, hn;
  static char [ ,]Dataset ;
  static bool [,] Counted ;
  static int output = 0;
  
  
  static void Main(string[] args){
    while (true){
      string[] read = Console.ReadLine().Split(' ');
      w = int.Parse(read[0]);
      h = int.Parse(read[1]);
      if(w == 0 || h == 0)break;
      
      Dataset = new char[w,h];
      for(int i = 0; i < h ; i++){
        string iread = Console.ReadLine();
        for(int j = 0; j< w ; j++){
          Dataset[j,i] = iread[j]; 
          if(Dataset[j,i] == '@' ){wn = j; hn = i;}
        }
      }
      
      Counted = new bool[w ,h] ;
      Check();
      Console.WriteLine(output);
      output = 0;
    }
    
    
  } 
  
  static void Check( ){
      Counted[wn,hn]= true;
      output ++;
      
        if(wn != 0 && !Counted[wn - 1 ,hn] && Dataset[wn -1,hn] != '#' ){
          wn --;Check();wn++;
        }if(hn != 0 && ! Counted[wn,hn - 1] && Dataset[wn,hn - 1] != '#'){
          hn --;Check();hn++;
        }if(wn != w - 1 && !Counted[wn + 1,hn] && Dataset[wn + 1,hn]  != '#'){
          wn ++;Check();wn--;
        }if(hn != h - 1 && !Counted[wn,hn + 1] && Dataset[wn,hn + 1] != '#'){
          hn ++;Check();hn--;
        }
    }
  
}
/*

    int a,b,c;
    a = int.Parse(Console.ReadLine()); //標準入力
    string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
    b = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
    c = int.Parse(str[1]);
　　Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
    Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力

*/

Measured memory_bytes: 5816
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N;
	string A, B, C;
	cin >> N >> A >> B >> C;
	ll an = 2 * N;
	rep(i, N) {
		if (A.at(i) == B.at(i) && C.at(i) == B.at(i)) {
			an -= 2;
		}
		else if (A.at(i) == B.at(i) || C.at(i) == B.at(i)|| C.at(i) == A.at(i)) {
			an -= 1;
		}
		
	}

	cout << an << endl;
}


Measured memory_bytes: 256
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))

    def value(v):
        cnt = 0
        for i in a:
            cnt += (i-1)//v
        if cnt > k:
            return False
        else:
            return True

    def b_search(ok, ng, value):
        while abs(ok-ng) > 1:
            mid = (ok+ng)//2
            if value(mid):
                ok = mid
            else:
                ng = mid
        return ok

    print(b_search(10**16, 0, value))


main()


Measured memory_bytes: 30844
#include <iostream>
#include <cstring>
using namespace std;
char s[105];
int i,n;
bool okc;
int main()
{
    cin>>s;
    n=strlen(s);
    for(i=0;i<n;i++)
    {
        if(s[i]=='C')
            okc=true;

        if(s[i]=='F' && okc)
        {
            cout<<"Yes";
            return 0;
        }

    }
    cout<<"No";
    return 0;
}


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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

  int N;
  ll K;
  cin >> N >> K;
  int P[N];
  REP(i,N) cin >> P[i];
  ll C[N];
  REP(i,N) cin >> C[i];

  ll ans = -MOD;
  REP(i,N) {
    int pos = i;
    ll score = 0;
    ll len = 0;
    bool skipped = false;
    while (len < K) {
      pos = P[pos] - 1;
      chmax<ll>(ans, score += C[pos]);
      len++;
      if (!skipped && pos == i && (K-EPS)/len > 1) {
        if (score < 0) break;
        score *= (ll)((K-EPS)/len - 1);
        chmax<ll>(ans, score);
        len *= (ll)((K-EPS)/len - 1);
        skipped = true;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
int N;
int arr[110];
int main(void)
{
    cin >> N;
    for (int i = 0; i < N; ++i)
        cin >> arr[i];

    int sum = accumulate(arr, arr + N, 0);

    double ave = (double)sum / N;
    double value = 100000.0, idx = 0;

    for (int i = 0; i < N; ++i)
    {
        if (value > abs((double)arr[i] - ave))
        {
            idx = i;
            value = abs((double)arr[i] - ave);
        }
    }
    cout << idx << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iostream>
#include<algorithm>//next_permutation

using namespace std;
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	bool F = false;
	if (A == B && B != C) {
		F = true;
	}
	if (A == C && B != C) {
		F = true;
	}
	if (C == B && B != A) {
		F = true;
	}
	if (F) {
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int m = a[0];
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(m >= a[i]) {
            ans++;
        }
        m = min(m, a[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
n,l = map(int,input().split())

if l+n-1 <=0:
    minL = l+n-1
elif l<=0 and l+n-1 >=0:
    minL = 0
elif l>=0:
    minL  = l

taste = n*(2*l+n-1)/2-minL

print(int(taste))

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)
#define fs first
#define sc second

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main(){
	map<int,int> ten;
	rep(i,13){
		ten[(i*10)%13]=i;
	}
	string s; cin >> s;
	int n = s.size();
	vector<vector<mint>> dp(n+1,vector<mint>(13,0));
	dp[0][0] = 1;
	rep(i,n){
		rep(j,13){
			if(s[i] == '?'){
				rep(k,10){
					dp[i+1][j] += dp[i][ten[(j-k+13)%13]];
				}
			}else{
				dp[i+1][j] = dp[i][ten[(j-(s[i]-'0')+13)%13]];
			}
		}
	}
	cout << dp[n][5] << endl;
}

Measured memory_bytes: 19828
in_string = input()
in_arr = in_string.split()
N = int(in_arr[0])
A = int(in_arr[1])
B = int(in_arr[2])

if ((B-A) % 2) == 0:
    print(int((B-A)//2))
else:
    if (N-B) > A-1:
        print(int(A+(B-A-1)//2))
    else:
        print(int(N-B+1+((N-(A+N-B+1))//2)))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,N;
  cin>>H>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int a = 0;
  for(int i=0;i<N;i++){
    H = H-vec.at(i);
    if(H<=0){
      a++;
    }
  }
  if(a>=1){
    cout<<"Yes"<<endl;
  }
  else if(a==0){
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 640