akhauriyash/Code-Regression huggingface dataset:
M = int(input())

cur = 0

keta = 0
csum = 0
for _ in range(M):
  d,c = map(int,input().split())
  s = 0
  for i in str(d):
    s += int(i)
  csum += s * c
  keta += c

# 9をカウントしたくないため
print(keta-1 + (csum-1)//9)

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

ll dp[20007];

struct node
{
  int w, s;
  ll v;
}a[1007];

bool cmp(node &x, node &y) 
{
  return x.w + x.s < y.w + y.s;
}

int main()
{
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
      cin>>a[i].w;
      cin>>a[i].s;
      cin>>a[i].v;
      //scanf("%d%d%lld", &a[i].w, &a[i].s, &a[i].v);
    }
    sort(a + 1, a + 1 + n, cmp);
    ll ans = 0;
    for (int i = 1; i <= n; i++)
        for (int j = a[i].s + a[i].w; j >= a[i].w; j--)
            ans = max(ans, dp[j] = max(dp[j], dp[j - a[i].w] + a[i].v));
  cout<<ans;  
  //printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,k;
long long a[200100];
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=k+1;i<=n;i++){
		if(a[i]>a[i-k]) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 5168
// https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_b

#include <bits/stdc++.h>
using namespace std;

int main()
{
    vector<int> a(101, -1);
    for (int i = 0; i < 9; i++)
    {
        int x;
        cin >> x;
        a[x] = i;
    }

    vector<int> called_row(3, 0);
    vector<int> called_col(3, 0);
    int d = 0;
    int u = 0;

    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int b;
        cin >> b;
        // cout << b << endl;
        if (a[b] == -1)
            continue;
        int r = a[b] / 3;
        int c = a[b] % 3;
        called_row[r]++;
        called_col[c]++;
        if (r == c)
            d++;
        if (r + c == 2)
            u++;
        // cout << called_row[0] << called_row[1] << called_row[2] << endl;
    }

    bool cond = false;
    cond |= (d == 3);
    cond |= (u == 3);
    for (int i = 0; i < 3; i++)
    {
        cond |= (called_row[i] == 3);
        cond |= (called_col[i] == 3);
    }
    cout << (cond ? "Yes" : "No") << endl;
    return 0;
}


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

//O(k)で nCk%MOD を求める

const int MOD = 1000000007;
long long int POW(int a,int n){
	long long int r;
	if(n==0)return 1;
	r=POW(a,(n-n%2)/2)%MOD;
	r=(r*r)%MOD;
	if(n%2)r=(a*r)%MOD;
	
	return r;
}
long long int COM(int n,int k){
	long long int p=1,q=1;
	for(int i=n;i>n-k;i--)p=(p*i)%MOD;
	for(int i=2;i<=k;i++)q=(q*i)%MOD;
	return (p*POW(q,MOD-2))%MOD;
}

int main(){
	int N,M;
	cin>>N>>M;
	cout<<COM(N,2)+COM(M,2);
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [True for _ in range(N + 1)]
for _ in range(M):
    A[int(input())] = False
num = [0 for _ in range(N + 1)]
num[0] = num[1] = 1
for n in range(2, N + 1):
    if not A[n]:
        continue
    if A[n - 1]:
        num[n] += num[n - 1]
    if A[n - 2]:
        num[n] += num[n - 2]
    num[n] %= 10 ** 9 + 7
print(num[N] % (10 ** 9 + 7))


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


int main(){
    int x; cin >> x;
    bool flag = true;
    for(int j = x;j >0;j++){
    for(int i=2;i*i<x;i++){
        if(j % i == 0){
            flag = false;
            break;
        }else{
            flag = true;
        }
    }if(flag){
        cout << j << endl;
        break;
    }
    }
  
}

Measured memory_bytes: 256
/*
          , -- 、
        /;;;;;;', 　　　
        i二二二i
      , ' 　    ヽ ???
     i　ﾉﾉﾉﾉﾉﾍ .', 　　
     〉ﾘi' ﾟ ヮﾟﾉﾚく　 WAyon..........
  ○⊂}〈lﾄ--ｲl〉{つ● 　　
      ,ｒ/ー i-ヽヽ 　　　
     ｀｀i_ﾗi_ﾗ
*/



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

const int INF=(long long)1e12;
const int mod=(int)1e9+7;
#define all(a) (a).begin(),(a).end()
typedef vector<vector<int>> graph;
int sz=262144;complex<double> y[262160],A[262160],B[262160];
#define int long long
#define pb push_back

void dft(complex<double> *x,bool inv);
#define P pair<int,int>





signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int x,y,a,b,c;cin >>x>>y>>a>>b>>c;
    vector<int> A(a),B(b),C(c);
    rep(i,a)cin >>A[i];
    rep(i,b)cin >>B[i];
    rep(i,c)cin >>C[i];
    sort(all(A));reverse(all(A));
    sort(all(B));reverse(all(B));
    sort(all(C));reverse(all(C));
    vector<int> tp;
    rep(i,x)tp.pb(A[i]);
    rep(i,y)tp.pb(B[i]);
    rep(i,c)tp.pb(C[i]);
    sort(all(tp));reverse(all(tp));int ans=0;
    rep(i,x+y){
        ans+=tp[i];
    }
    cout <<ans<<endl;
}

void dft(complex<double> *x,bool inv){
    for(int i=sz>>1;i>=1;i>>=1){
        complex<double> zeta=polar(1.0,2.0*acos(-1)*i/sz*(inv?-1.0:1.0)),now=1;
        for(int j=0;2*j<sz;j+=i){//i飛ばし
            rep(k,i) {
                y[k+j]=x[2*j+k]+now*x[2*j+i+k];
                y[j+k+(sz/2)]=x[2*j+k]-now*x[2*j+i+k];//sz/2以上のやつ。原点対称を利用
            }
            now*=zeta;
        }
        rep(i,sz)x[i]=y[i];//探索の区間の幅を狭める前にこぴー
    }

    if(inv)rep(i,sz)x[i]/=sz;

}

Measured memory_bytes: 8816
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int five  = 0;
    int seven = 0;
    for(int i = 0; i < 3; i++) {
        int a;
        cin >> a;
        if(a == 5) five++;
        if(a == 7) seven++;
    }
    if(five == 2 && seven == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}

#[allow(unused_macros)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn a() {
    let (a, b) = read!(i32, i32);
    println!("{}", max(0, a - 2 * b));
}

fn b() {
    let n = read!(usize);
    let d: Vec<usize> = read![[usize]];

    let mut ans = 0;
    for i in 0..(n - 1) {
        for j in (i + 1)..n {
            ans += d[i] * d[j];
        }
    }
    println!("{}", ans);
}

fn c() {
    let n = read!(usize);
    let s: String = read!(String);

    let c: Vec<char> = s.chars().collect();

    let mut prev = c[0];
    let mut ans = 0;
    for i in 0..n {
        if prev == c[i] {
            continue;
        } else {
            ans += 1;
            prev = c[i];
        }
    }
    println!("{}", ans + 1);
}

fn d() {
    unimplemented!();
}

fn e() {
    unimplemented!();
}

fn f() {
    unimplemented!();
}

fn main() {
    c();
}


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

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
  
    sort(a.begin(), a.end());

    for (const string s : a) {
        cout << s;
    }

    cout << endl;
}


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

#define F first
#define S second
#define pb push_back
#define ld long double
//#define int long long
#define ll long long

using namespace std;

const int MAXN = 1001 * 1001 ;

int cnt[MAXN] ;

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

    int n , mx = -1 , mn = 1e9 ;

    cin >> n ;

    for(int i = 0 ; i < n ; i ++ )
    {
        int x ;
        cin >> x ;
        cnt[x] ++ ;
        mx = max(mx,x) ;
        mn = min(mn,x) ;
    }

    if(mx-mn>1) return cout << "No" << endl , 0 ;
    if(mx==mn)
    {
        if(mx<=n/2||mx==n-1) return cout << "Yes" << endl , 0 ;
        return cout << "No" << endl , 0 ;
    }
    if(mn!=mx)
    {
        n -= cnt[mn] ;
        mx -= cnt[mn] ;
        if(mx<=0) return cout << "No" << endl , 0 ;
        cnt[mx] = cnt[mx+cnt[mn]] ;
     //   cout << n << ' ' << mx << endl ;

        if(mx<=n/2) return cout << "Yes" << endl , 0 ;
        return cout << "No" << endl , 0 ;
    }

    return 0;
}


Measured memory_bytes: 640
#Ns,Ms,=input().split()
#N=int(Ns)
#M=int(Ms)
#H=list(map(int,input().split()))
#A=[]
#B=[]
#ans_arr=[]
flag=True
A=0
B=0
Ax=0
Bx=0
X=int(input())
while flag:
    for B in range(0,A+1):
        if X== (pow(A,5)-pow(B,5)):
            if flag==True:
               Bx=B
               Ax=A
            flag=False
        elif X== (pow(A,5)+pow(B,5)):
            if flag==True:
               Bx=-B
               Ax=A
            flag=False
    A+=1
print(str(Ax)+" "+str(Bx))


Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,f=0,g;
  int d[1000][1000];
  int e[1000];
  cin>>a>>b>>c;
  for(int i=0;i<b;i++){
    cin>>e[i];
  }
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      cin>>d[i][j];
    }
  }
  for(int i=0;i<a;i++){
    g=0;
    for(int j=0;j<b;j++){
      g=d[i][j]*e[j]+g;
    }
    if(g+c>0){
      f++;
    }
  }
  cout<<f<<"\n";
}


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

int main() {
	int64_t n, m; cin >> n >> m;
	vector<int64_t> a(n); for(int i = 0; i < n; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	// 幸福度mid以上の握手がm回以上できるか
	int64_t ok = 0, ng = 1e18;
	while(abs(ok - ng) > 1) {
		int64_t mid = (ok + ng) / 2;
		int64_t cnt = 0;
		for(int i = 0; i < n; ++i) {
			// 左でa[i]を持つと右はmid-a[i]以上であってほしい
			int64_t tmp = a.end() - lower_bound(a.begin(), a.end(), mid - a[i]);
			tmp = min(tmp, n - i);
			tmp <<= 1ll;
			if(a[i] * 2 >= mid) --tmp;
			cnt += tmp;
		}
		if(cnt >= m) {
			ok = mid;
		} else {
			ng = mid;
		}
	}
	int64_t sum[n + 1] = {};
	for(int i = 1; i <= n; ++i) {
		sum[i] = sum[i - 1] + a[n - i];
	}
	int64_t ans = 0, cnt = 0;
	for(int i = 0; i < n; ++i) {
		int64_t idx = a.end() - lower_bound(a.begin(), a.end(), ok - a[i]);
		idx = min(idx, n - i);
		ans += (a[i] * idx + sum[idx]) * 2;
		cnt += idx * 2;
		if(a[i] * 2 >= ok) {
			--cnt;
			ans -= a[i] * 2;
		}
	}
	if(cnt > m) {
		ans -= ok * (cnt - m);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

void solve() {
    auto v = make_v(10, 10, 0);
    auto ans = v;
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            cin >> v[i][j];
        }
    }
    auto s = v;
    auto flip = [&](int y, int x)  {
        ans[y][x] ^= 1; v[y][x] ^= 1;
        if(y) v[y-1][x] ^= 1;
        if(x) v[y][x-1] ^= 1;
        if(y != 9) v[y+1][x] ^= 1;
        if(x != 9) v[y][x+1] ^= 1;
    };
    for (int i = 0; i < (1 << 10); ++i) {
        for (int j = 0; j < 10; ++j) {
            for (int k = 0; k < 10; ++k) {
                ans[j][k] = 0;
            }
        }
        v = s;
        for (int j = 0; j < 10; ++j) {
            if(i & (1 << j)) flip(0, j);
        }
        for (int j = 1; j < 10; ++j) {
            for (int k = 0; k < 10; ++k) {
                if(v[j-1][k]) flip(j, k);
            }
        }
        int ok = 1;
        for (int j = 0; j < 10; ++j) {
            if(v[9][j]) ok = 0;
        }
        if(ok){
            for (int j = 0; j < 10; ++j) {
                for (int k = 0; k < 10; ++k) {
                    printf(k ? " %d" : "%d", ans[j][k]);
                }
                puts("");
            }
            return;
        }
    }
}

int main() {
    int n;
    cin >> n;
    while(n--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  for(int i=0;i<k;i++){
    if(a>=b)b*=2;
    else c*=2;
  }
  if(a<b && b<c){
    cout<<"Yes\n";
  }else{
    cout<<"No\n";
  }

  return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

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

		while (true) {
			String line = sc.nextLine();

			if (line.equals("0")) {
				break;
			}
			int result = 0;
			for (int i = 0; i < line.length(); i++) {
				String str = line.substring(i, i + 1);
				int n = Integer.parseInt(str);
				result += n;
			}
			System.out.println(result);

		}
	}

}

Measured memory_bytes: 26688
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int p[21];
    int ans = 0;
    rep(i, n) cin >> p[i];
    REP(i, 1, n - 2) {
        vector<int> v;
        rep(j, 3) v.push_back(p[i - 1 + j]);
        sort(v.begin(), v.end());
        if(v[1] == p[i]) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//package beg_163;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		
		int a = s.nextInt();
		
		double b= (double) a;
		
		System.out.println(2*b*3.14159265);

	}

}


Measured memory_bytes: 35992
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //cout<<7/(-4)<<" "<<7%(-4)<<endl;
    ll n,x,d;cin>>n>>x>>d;
    if(d==0){
        if(x==0)cout<<1<<endl;
        else cout<<n+1<<endl;
        return 0;
    }
    map<ll,vector<pll>> mp;
    set<ll> st;
    rep(i,0,n+1){
        
        ll sl=i*(i-1)*d+2*i*x+4000000000000000000,sr=i*(2*n-i-1)*d+2*i*x+4000000000000000000;
        ll r=sl%(2*d);
        st.insert(r);
        sl/=2*d;sr/=2*d;
        if(sl>sr)swap(sl,sr);
        mp[r].push_back({sl,sr});
    }
    ll ans=0;
    /*for(auto e:mp[0]){
        cout<<e.first<<" "<<e.second<<endl;
    }*/
    srep(itr,st){
        ll now=*itr;
        sort(mp[now].begin(),mp[now].end());
        ll nr=mp[now][0].second,nl=mp[now][0].first;
        ans+=nr-nl+1;
        rep(i,1,mp[now].size()){
            //cout<<nr<<" "<<nl<<endl;
            //cout<<ans<<endl;
            ll nnr=mp[now][i].second,nnl=mp[now][i].first;
            //cout<<nnr<<" "<<nnl<<endl;
            if(nnl>nr){
                ans+=nnr-nnl+1;
                nl=nnl;
                nr=nnr;
            }
            else{
                if(nnr>nr){
                    ans+=nnr-nr;
                    nl=nnl;
                    nr=nnr;
                }
                else{
                    nl=nnl;
                }
            }
        }
    }
    cout<<ans<<endl;
}







Measured memory_bytes: 31488
#include <iostream>

using namespace std;

int main()
{
    int A, B, C, D;
    int sum;

    cin >> A >> B >> C >> D;

    if( A <= B )
        sum = A;
    else
        sum = B;
    
    if( C <= D )
        sum += C;
    else
        sum += D;
    
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int main() {
	int a, b, c[10] = { 0 }, i, j;
	while (1) {
		cin >> a;
		if (a == 0) 
			return 0;
		for (i = 0; i < a; i++) {
			cin >> b;
			c[b]++;
		}
		for (i = 0; i < 10; i++) {
			for (j = 0; j < c[i]; j++) 
				cout << "*";
			if (j == 0) {
				cout << "-";
			}
			cout << endl;
		}
		memset(c, 0, sizeof(c));
	}
}

Measured memory_bytes: 3020
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

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

  vector<double> A(N, 0);
  double sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }

  double avg = sum / (double)N;

  double diff = 1 << 29;
  for (int i = 0; i < N; i++) {
    if (abs(avg - A[i]) < diff) {
      ans  = i;
      diff = abs(avg - A[i]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// review

#include <iostream>
#include <cstring>

using namespace std;
typedef long long ll;
const int MAXN = 1e5+10;
const int MAXK = 2010;

int n, k;
ll x[MAXN], y[MAXN];
char c[MAXN];

int board[MAXK][MAXK];

int get(int sx, int sy, int ex, int ey) {
  int tmp = board[ey][ex];
  if (sx >= 0) {
    tmp -= board[ey][sx];
  }
  if (sy >= 0) {
    tmp -= board[sy][ex];
  }
  if (sx >= 0 && sy >= 0) {
    tmp += board[sy][sx];
  }

  return tmp;
}

void solve() {
  for (int i=0;i<n;i++) {
    if (c[i] == 'W') {
      x[i] += k;
    }
    x[i] = x[i] % (2 * k);
    y[i] = y[i] % (2 * k);
  }

  memset(board, 0, sizeof(board));

  for (int i=0;i<n;i++) {
    board[y[i]][x[i]]++;
  }

  for (int y=0;y<2*k;y++) {
    for (int x=1;x<2*k;x++) {
      board[y][x] += board[y][x-1];
    }
  }
  for (int y=1;y<2*k;y++) {
    for (int x=0;x<2*k;x++) {
      board[y][x] += board[y-1][x];
    }
  }

  int maxCnt = 0;
  for (int y=0;y<k;y++) {
    for (int x=0;x<k;x++) {
      int cnt = get(-1, -1, x, y) +
                get(x + k, -1, 2 * k - 1, y) +
                get(-1, y + k, x, 2 * k - 1) +
                get(x, y, x + k, y + k) +
                get(x + k, y + k, 2 * k - 1, 2 * k - 1);
      maxCnt = max(maxCnt, (max(cnt, n - cnt)));
    }
  }

  cout << maxCnt << endl;
}

int main() {
  cin >> n >> k;
  for (int i=0;i<n;i++) {
    cin >> x[i] >> y[i] >> c[i];
  }
  solve();
}


Measured memory_bytes: 17664
h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]
X = [-1, 0, 1]
Y = [-1, 0, 1]

for i in range(h):
    for j in range(w):
        if S[i][j] == '.':
            count = 0
            for x in X:
                for y in Y:
                    if (i == 0 and x == -1) or (i == h-1 and x == 1):
                        continue
                    if (j == 0 and y == -1) or (j == w-1 and y == 1):
                        continue
                    if S[i+x][j+y] == '#':
                        count += 1
        else:
            continue
        S[i][j] = count

for s in S:
    print(''.join(map(str, s)))

Measured memory_bytes: 3064
D, G = map(int, input().split())
P = []
C = []
for i in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)

anslist = []
def dfs(i, total, count, nokori):
    # print("i = {}, total = {}, count = {}, nokori = {}".format(i, total, count, nokori))


    if G <= total:
        anslist.append(count)
        # print("    G: count = {}".format(count))
        return
    if i == D:
        if G > total:
            if len(nokori) == 0:
                return
            for c in sorted(list(nokori), reverse=True):
                for _ in range(P[c]):
                    total += 100*(c+1)
                    count += 1
                    if G <= total:
                        anslist.append(count)
                        # print("        G: count = {}".format(count))
                        return
                # print("    c = {}, total = {}".format(c, total))
        return
    dfs(i+1, total, count, nokori)
    dfs(i+1, total + 100*(i+1)*P[i]+C[i], count + P[i], nokori - {i})

dfs(0, 0, 0, set(range(D)))
print(min(anslist))

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    bool result;
    if(a==7 && b==5 && c==5 || b==7 && a==5 && c==5 || c==7 && a==5 && b==5){
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split(' ')))
a.insert(0, -1)
#print(a)

M = 0
b = [0 for i in range(N)]
b.insert(0, -1)
for i in reversed(range(1, N + 1)):
    num = 0
    for j in range(1, N // i + 1):
        num ^= b[j * i]
    b[i] = a[i] ^ num

print(b.count(1))
for i in range(1, N + 1):
    if b[i] == 1:
        print(i, end=' ')

Measured memory_bytes: 7248
#include<bits/stdc++.h>
using namespace std;
string st;
int main()
{
	cin>>st;
	for (int i=0;i<st.size();i++)
	  if (st[i]==st[i+1]&&st[i+2]==st[i]) {cout<<"Yes"<<endl;return 0;}
	cout<<"No"<<endl;
	return 0;
}


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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> w(100), v(100);
  vector<vector<ll>> dp(101, vector<ll>(m + 1, 0));

  for (ll i = 0; i < n; i++) {
    cin >> w[i] >> v[i];
  }
  for (ll i = 0; i < n; i++) {
    for (ll j = 0; j <= m; j++) {
      if (j - w[i] >= 0) {
        if (dp[i][j] > dp[i][j - w[i]] + v[i]) {
          dp[i + 1][j] = dp[i][j];
        } else {
          dp[i + 1][j] = dp[i][j - w[i]] + v[i];
        }
      }else{
        dp[i + 1][j] = dp[i][j];
      }
    }
  }
  /*
  for (ll i = 0; i <= n; i++) {
    for (ll j = 0; j <= m; j++) {
      cout << dp[i][j] << " " << flush;
    }
    cout << endl;
  }*/
  cout << dp[n][m] << endl;
  return 0;
}

Measured memory_bytes: 80256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		String s = scan.next();
		String p = scan.next();
		
		s = s.concat(s);
		int num = s.indexOf(p);
		
		if(num != -1) System.out.println("Yes");
		else          System.out.println("No");
		
		scan.close();
	
		
	}

}

Measured memory_bytes: 17276
import math
N = int(input())
digit = math.ceil(math.log((25 * N / 26 + 1), 26))

alphabet = list("abcdefghijklmnopqrstuvwxyz")

name = []

for i in range(digit):
  name.append((N % 26 - 1) % 26)
  N = (N - (N % 26 - 1) % 26) // 26

name.reverse()
print("".join([alphabet[s] for s in name]))


Measured memory_bytes: 9112
#include <iostream>
using namespace std; 
int main()
{
  int r,g,b;
 cin >> r >> g >> b;
 int t = r * 100 + g * 10 + b;
  if(t % 4 == 0)
    cout << "YES" << endl;
 else
   cout << "NO" << endl;

  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 REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int a, b; cin >> a >> b;
    if(a < b) cout << "a < b" << endl;
    if(a == b) cout << "a == b" << endl;
    if(a > b) cout << "a > b" << endl;

    return 0;
}


Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>
#include <bitset>
#include <sstream>
#include <cassert>
#include <time.h>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
void printvec (vec &v) {
    Rep (i, (ll)v.size()) {
        cout << v[i] << " \n"[i+1 == (ll)v.size()];
    }
}

const int MOD = 998244353;
class mint {
    ll x;
public:
    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 {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator *(const mint &a) const {
        mint res(*this);
        return res *= 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 {
        mint res(*this);
        return res /= a;
    }

    friend ostream &operator<<(ostream& os, const mint &m) {
        os << m.x;
        return os;
    }
};




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

    ll N, K;
    cin >> N >> K;
    vec L(K), R(K);
    Rep (i, K) {
        cin >> L[i] >> R[i];
        R[i]++;
    }

    vector<mint> dp(N, mint(0));
    vector<mint> cnt(N, mint(0));
    dp[0] = mint(1);
    mint tmp(0);
    Rep (i, N) {
        tmp += cnt[i];
        dp[i] += tmp;

        Rep (j, K) {
            if (i + L[j] < N) cnt[i+L[j]] += dp[i];
            if (i + R[j] < N) cnt[i+R[j]] -= dp[i];
        }


    }

    cout << dp[N-1] << endl;

}

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

int main()
{
  int n;
  string s;
  cin>>n>>s;
  
  if(n%2!=0)
  {
    cout<<"No"<<endl;
    return 0;
  }
  
  for(int i=0;i<n/2;i++)
  {
    if(s.at(i)!=s.at(i+n/2))
    {
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}
  

Measured memory_bytes: 256
def solve(n):
    i = 0
    while i * 7 <= n:
        j = 0
        while 1:
            cnt = i * 7 + j * 4
            if cnt == n:
                return True
            elif cnt > n:
                break
            j += 1
        i += 1
    return False

if solve(int(input())):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll s,w;cin>>s>>w;
    if(s>w)cout<<"safe"<<endl;
    else cout<<"unsafe"<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include<set>
using namespace std;

int main() {
	int n;
	set <int> mochi;

	cin >> n;
	for (int i = 0; i < n; i++) {
		int d;
		cin >> d;
		mochi.insert(d);
	}
	cout << mochi.size() << endl;
}

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

using namespace std;

int main(void) {
    int n;
    cin>> n;
    vector <int> d(n);
    long long int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> d[i];
        for (int j = 0; j < i; j++) {
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	while (b > 0) {
		if (b & 1) {res = (res * a); b--;}
		a = (a * a);
		b >>= 1;
	}
	return res;
}
ll n;
ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}



int main() {
	
	ll n,k;
	k=2;
	cin>>n;
	vector <ll> a(n);
	for(ll i=0;i<n;i++)
		cin>>a[i];
	vector <ll> dp(n);
	dp[0]=0;
	for(ll i=1;i<n;i++){
		dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
		for(ll j=2;(j<=k&&i-j>=0);j++)
			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	}
	cout<<dp[n-1]<<"\n";
}


Measured memory_bytes: 4824
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
const int maxSize=2000;
vector<int>g[maxSize];
int dp[maxSize][maxSize];
int dp2[maxSize][maxSize];
int K;
int v[2100];
void calc(int a,int b){
	v[a]=1;
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i])continue;
		calc(g[a][i],a);
		v[a]+=v[g[a][i]];
	}
	for(int i=0;i<=g[a].size();i++)for(int j=0;j<=K;j++)dp2[i][j]=-999999;
	dp2[0][0]=1;
	int sz=0;
	int at=0;
	for(int i=0;i<g[a].size();i++){
		if(b==g[a][i])continue;
		for(int j=0;j<=sz;j++){
			dp2[at+1][j]=max(dp2[at+1][j],dp2[at][j]);
			for(int k=0;j+k+1<=K;k++){
				dp2[at+1][max(j,k+1)]=max(dp2[at+1][max(j,k+1)],dp2[at][j]+dp[g[a][i]][k]);
			}
		}
		at++;
		sz+=v[g[a][i]];
	}
	for(int i=0;i<=K;i++)dp[a][i]=dp2[at][i];
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	K=b;
	for(int i=0;i<a-1;i++){
		int p,q;scanf("%d%d",&p,&q);
		p--;q--;
		g[p].push_back(q);
		g[q].push_back(p);
	}
	calc(0,-1);
	int ret=0;
	for(int i=0;i<a;i++)for(int j=0;j<=b;j++)
		ret=max(ret,dp[i][j]);
	printf("%d\n",a-ret);
}


Measured memory_bytes: 25132
#include<stdio.h>

int main(void){
  int i,n,c=0;
  int a[4];

  scanf("%d",&n);

  for(i=0;i<4;i++){
    a[i] = n%10;
    n/=10;
  }


  if(a[0]==a[1]&&a[1]==a[2]||a[1]==a[2]&&a[2]==a[3])
    printf("Yes\n");

  else
    printf("No\n");

  return 0;
}
    


Measured memory_bytes: 128
//I-Coins

#include<iostream>
#include<algorithm>
#include<utility>
#include<map>
#include<string>
#include<vector>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#undef INT_MIN
#undef INT_MAX
#define LL long long
#define INT_MIN -2147483647
#define INT_MAX 1000000009
#define LL_MIN -9223372036854775807
#define LL_MAX 9223372036854775807
#define MP make_pair
#define PB push_back
#define MOD 1000000007

int N;
double par[3000];
double dp[3001][3001] = {};
double ans = 0;

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

	for(int i = 0; i <= N; i++){
		for(int j = 0; i + j <= N; j++){
			if((i == 0) && (j == 0)){
				dp[i][j] = 1;
			}
			else if(i == 0){
				dp[i][j] = dp[i][j - 1] * (1 - par[j]);
			}
			else if(j == 0){
				dp[i][j] = dp[i - 1][j] * par[i];
			}
			else{
				dp[i][j] = dp[i - 1][j] * par[i + j] + dp[i][j - 1] * (1 - par[i + j]);
			}

			if((i + j == N) && (i > N / 2))
				ans += dp[i][j];
			//cout << "dp[" << i << "][" << j << "] = " << dp[i][j] << endl;
		}
	}

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


Measured memory_bytes: 70016
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    string ans;
    ans.resize(2*n);
    for(int i = 0,k = 0;i < n;++i,k+=2){
        ans[k] = s[i];
        ans[k + 1] =  t[i];
    }
    cout << ans;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
S=input()
dp=[]
p,q=0,0
for i in S:
  if i=='1':
    if 0<q:
      dp.append(q)
    p+=1
    q=0
  else:
    if 0<p:
      dp.append(p)
    p=0
    q+=1
if 0<p:
  dp.append(p)
else:
  dp.append(q)
if S[0]=='0':
  if len(dp)<=2*K:
    print(sum(dp))
  else:
    if S[N-1]=='0':
      dp.append(0)
    dp.insert(0,0)
    ans=sum(dp[:2*K+1])
    bns=ans
    for i in range(2*K,len(dp),2):
      if i==2*K:
        continue
      bns+=dp[i]+dp[i-1]-dp[i-2*K-1]-dp[i-2*K-2]
      ans=max(ans,bns)
    print(ans)
else:
  if len(dp)<=2*K+1:
    print(sum(dp))
  else:
    if S[N-1]=='0':
      dp.append(0)
    ans=sum(dp[:2*K+1])
    bns=ans
    for i in range(2*K,len(dp),2):
      if i==2*K:
        continue
      bns+=dp[i]+dp[i-1]-dp[i-2*K-1]-dp[i-2*K-2]
      ans=max(ans,bns)
    print(ans)

Measured memory_bytes: 10396
import java.util.*;

public class Main{
    public static void main(String[] args){
        try{
            Scanner sc = new Scanner(System.in);
   
            int N = sc.nextInt();

            Map<Integer,Integer> map = new TreeMap<Integer, Integer>();
            for(int i = 0; i < N; i++){
                int X = sc.nextInt();
                int L = sc.nextInt();
                map.put(X,L);
            }

            int leftArm = -1000000000;
            int rightArm = 0;
            int removeNum = 0; 
      
            for (Integer key : map.keySet()){

                if(leftArm + rightArm > key - map.get(key)){
                    removeNum++;

                    if(leftArm + rightArm > key + map.get(key)){
                        leftArm = key;
                        rightArm = map.get(key);
                    }
                
                }else{
                    leftArm = key;
                    rightArm = map.get(key);                   
                }
            }   
            int ans = N - removeNum;
            System.out.println(ans);
   
        sc.close();

        }catch(NoSuchElementException e){
			System.out.println("無効な値です");
		}
    }
}

Measured memory_bytes: 98728
#include<stdio.h>
#include<string.h>
int main()
{
	int a,b,c,d,e,f,g,i;
	char x[1000];
	scanf("%d",&f);
	scanf("%s",x);
	a=f%2;
	b=f/2;
	if(a==1)
	{
		printf("No\n");
		return 0;
	}
	for(i=0;i<b;i++)
	{
		if(x[i]!=x[b+i])
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static final int MAX = Integer.MAX_VALUE/10;
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
		int V = in.nextInt();
		if(V==0) break;
		int E = in.nextInt();
		int s = in.nextInt()-1;
		int g1 = in.nextInt()-1;
		int g2 = in.nextInt()-1;
		int[][] road = new int[V][V];
		for (int i=0;i<V;i++) {
			for(int j=0;j<V;j++){
				road[i][j] = (i==j)?0:MAX;
			}
		}
		for(int i=0;i<E;i++){
			int a = in.nextInt()-1;
			int b = in.nextInt()-1;
			int c = in.nextInt();
			road[a][b] = c;
		}
/*		
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				System.out.print(road[i][j]+" ");
			}
			System.out.println();
		}
		System.out.println();
*/		
		for(int k=0;k<V;k++){
			for(int i=0;i<V;i++){
				for(int j=0;j<V;j++){
					road[i][j] = Math.min(road[i][j],road[i][k]+road[k][j]);
				}
			}
		}
/*		
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				System.out.print(road[i][j]+" ");
			}
			System.out.println();
		}
		System.out.println();
*/		
		int ans = Integer.MAX_VALUE;
		for(int i=0;i<V;i++){
			ans = Math.min(ans,road[s][i]+road[i][g1]+road[i][g2]);
//			System.out.println(i +":"+ans);
		}
		
		System.out.println(ans);
		System.gc();
		}
	}
}

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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<vector<int>> adj(N*3, vector<int>{});
	
	for (int i = 0; i < M; ++i)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		adj[a].push_back(b+N);
		adj[a+N].push_back(b+2*N);
		adj[a+2*N].push_back(b);
	}
	
	int S, T;
	cin >> S >> T;
	S--; T--;
	queue<int> q;
	vector<bool> visited(N*3, false);
	vector<int> distance(N*3, 0);
	
	q.push(S);
	visited[S] = true;
	distance[S] = 0;
	while (!q.empty())
	{
		int s = q.front(); q.pop();
		for (auto x : adj[s])
		{
			if (visited[x])
				continue;
			visited[x] = true;
			distance[x] = distance[s] + 1;
			q.push(x);
		}
	}
	
	if (visited[T])
		cout << distance[T] / 3 << '\n';
	else
		cout << -1 << '\n';
}


Measured memory_bytes: 17920
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cassert>
#include <string>
#include <cstring>
#include <bitset>
 
#define FOR(i, a, b) for(int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for(int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)
 
#define rsz resize
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define f first
#define s second
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;

const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, 30, +31, +30, +31, +31, +30, +31, +30, +31};

const int N = 2e5 + 5;
int a [N], b [N];

i64 seg [4 * N];

i64 query (int ql, int qr, int l, int r, int node) {
  if (l > qr || r < ql) return 0;
  if (l >= ql && r <= qr) return seg[node];
  int mid = l + (r - l) / 2;
  return max (query (ql, qr, l, mid, 2 * node + 1), query (ql, qr, mid + 1, r, 2 * node + 2) );
}

void update (int idx, i64 delta, int l, int r, int node) {
  if (l > idx || r < idx) return;
  if (l == idx && r == idx) {
    seg[node] = max (seg[node], delta);
    return;
  }
  int mid = l + (r - l) / 2;
  update (idx, delta, l, mid, 2 * node + 1);
  update (idx, delta, mid + 1, r, 2 * node + 2);
  seg[node] = max (seg[2 * node + 1], seg[2 * node + 2]);
}
  

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  F0R (i, n) cin >> a[i];
  F0R (i, n) cin >> b[i];
  i64 mx = 0;
  F0R (i, n) {
    int current_height = a[i];
    int current_profit = b[i];
    i64 best_previous = query (0, current_height - 1, 0, N - 1, 0);
    update (current_height, best_previous + current_profit, 0, N - 1, 0);
    mx = max (mx, best_previous + current_profit);
  }
  cout << mx << '\n';
  return 0;
}


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

long long n, m;
string a, b;

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

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

    long long l = 1LL*n*m/gcd( n, m );

    long long d1 = l/n, d2 = l/m;
    for ( long long i = 0 ; i < n ; i ++ ) {
        long long to1 = d1*i;

        if ( to1%d2 == 0 ) {
            if ( a[i] != b[ to1/d2 ] ) {
                //cout << "error " << to1 << " : " << a[i] << " " << b[to1/d2] << "\n";

                cout << "-1\n";
                return 0;
            }
        }
    }

    cout << l << "\n";

    return 0;
}


Measured memory_bytes: 512
#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>;
const int INF = 1000000007;

int main() {
  string s, t;
  cin >> s >> t;
  int cnt = 0;
  rep(i, s.length()) {
    if (s[i] != t[i]) cnt++;
  }
  cout << cnt << endl;
}


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

int main() {
  int n; cin >> n;
  set<int> a;
  rep(i, n) {
    int t; cin >> t;
    a.insert(t);
  }
  if ((int)a.size() == n) cout << "YES";
  else cout << "NO";
  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n,k;
	cin>>n>>k;

	lli sum=0;

	if(k==0){
		cout<<n*n<<endl;
		return 0;
	}

	REP(i,1,n+1){
		if(i<=k)continue;
		lli tmp = (n+1)/i * (i-k) + max(0LL,(n+1)%i-k);
		if(DEBUG)cout<<"i="<<i<<" tmp="<<tmp<<endl;
		sum += tmp;
	}

	cout<<sum<<endl;

	return 0;
}

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

int main(void){
  int N;

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

  int ans = 0;

  for (int l = 1; l < N+1; l++){
    if( (a[l]%2) == 1){
      if(l%2 == 1){
        ans = ans + 1;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3196
import sys
input = sys.stdin.readline

import numpy as np

def main():
    n,k = map(int, input().split())
    h_list = list(map(int, input().split()))

    c = 0
    for i in h_list:
        if i >= k:
            c += 1

    print(c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 21628
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	H, _ := strconv.Atoi(sc.Text())

	sc.Scan()
	W, _ := strconv.Atoi(sc.Text())

	que := make(queue, 0)

	maps := make([][]byte, H)
	for i := 0; i < H; i++ {
		sc.Scan()
		maps[i] = []byte(sc.Text())
		for j := 0; j < W; j++ {
			if maps[i][j] == '#' {
				que = que.Push([]int{i, j, 0})
			}
		}
	}

	maxCount := 0
	for len(que) > 0 {
		var cur []int
		cur, que = que.Pop()

		nexts := [][]int{
			{cur[0] - 1, cur[1], cur[2] + 1},
			{cur[0] + 1, cur[1], cur[2] + 1},
			{cur[0], cur[1] - 1, cur[2] + 1},
			{cur[0], cur[1] + 1, cur[2] + 1},
		}

		for _, next := range nexts {
			if next[0] >= 0 && next[0] < H &&
				next[1] >= 0 && next[1] < W &&
				maps[next[0]][next[1]] == '.' {
				que = que.Push(next)
				maps[next[0]][next[1]] = '#'
				if next[2] > maxCount {
					maxCount = next[2]
				}
			}
		}
	}
	fmt.Println(maxCount)
}

type queue [][]int

func (q queue) Push(p []int) queue {
	return append(q, p)
}

func (q queue) Pop() ([]int, queue) {
	if len(q) == 1 {
		return q[0], make(queue, 0)
	}
	return q[0], q[1:]
}


Measured memory_bytes: 117984
import java.io.*
import java.util.*
import java.lang.Math.*


fun primeFactorize(N: Long): Map<Long, Int> {
    if (N <= 1L) return mapOf()
    val fact = mutableMapOf<Long, Int>()
    var n = N
    var i = 2L
    while (i * i <= n) {
        while (n%i == 0L) {
            fact[i] = (fact[i] ?: 0) + 1
            n /= i
        }
        i++
    }
    if (n != 1L) {
        fact[n] = (fact[n] ?: 0) + 1
    }
    return fact
}


fun main() {
    val N = rd.readLong()

    val fs = primeFactorize(N).toMutableMap()

    var ans = 0
    var num = 1
    while (true) {
        var updated = false
        for ((k, v) in fs) {
            if (v >= num) {
                fs[k] = fs[k]!! - num
                ans++
                updated = true
            }
        }
        if (!updated) break
        num++
    }


    println(ans)
}


//val rd = debug.Reader("abc", "169", "d", "sample-1")
val rd = Reader()
fun main(args: Array<String>) {
    Thread(null, MainThread(), "mainThread", 128 * 1024 * 1024).start()
}


const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int)
data class To(val idx: Int, val cost: Long)
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
class MainThread : Runnable {
    override fun run() { main() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 35200