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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (max(max(a, b), c) * 2 == a + b + c) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    
    int n;
    cin>>n;
    vector<pair<int,int>> v;
    int fst=0, lst=0;
    ffor(i,0,n)
    {
        string s;
        cin>>s;
        stack<int> st;
        for(auto ch:s)
        {
            if(ch=='(') st.push(1);
            else
            {
                if((!st.empty())&&st.top()==1) st.pop();
                else st.push(-1);
            }
        }
        int len=sz(st);
        int c=0;
        while((!st.empty())&&st.top()==1)
        {
            st.pop();
            c++;
        }
     //   cout<<c<<" "<<len-c<<endl;
        if(c==len) fst+=c;
        else if(c==0) lst+=len;
        else v.pb({c,len-c});
    }
    sort(all(v), [](auto a,auto b){
        return a.ff-a.ss>b.ff-b.ss;
    });

    int cnt=fst;
    for(auto i:v) 
    {
        if(cnt-i.ss<0)
        {
            cout<<"No";
            return 0;
        }
        cnt+=i.ff-i.ss;
    }
    if(cnt==lst) cout<<"Yes";
    else cout<<"No";

    
    return 0;
}



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

using namespace std;

const int N = 1e6 + 6;

int a[N], p[N];

int main() {
  int n;
  scanf("%d", &n);
  int m = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    p[x] = p[x-1] + 1;
    m = max(m, p[x]);
  }
  printf("%d\n", n-m);
  return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

from math import sqrt
from itertools import accumulate


def is_prime(x):
    if x < 2:
        return False
    else:
        for i in range(2, int(sqrt(x)) + 1):
            if x % i == 0:
                return False
        return True


def is_like_2017(x):
    if is_prime(x) and is_prime((x + 1) // 2):
        return True
    else:
        return False


q = int(input())
lr = [list(map(int, input().split())) for _ in range(q)]

nums = []
for i in range(1, 10 ** 5, 2):
    if is_like_2017(i):
        nums.append(1)
    else:
        nums.append(0)

acm = [0] + list(accumulate(nums))
for l, r in lr:
    ans = acm[(r+1)//2] - acm[(l+1)//2-1]
    print(ans)



Measured memory_bytes: 30144
args=input().split()
N=int(args[0])
K=int(args[1])
args=input().split()
R=int(args[0])
S=int(args[1])
P=int(args[2])
T=input()

resSS=[]
for i in T:
  if i=="r":
    resSS.append(P)
  elif i=="s":
    resSS.append(R)
  else:
    resSS.append(S)

if N>=K:
  for i in range(N-K):
    if T[i+K]==T[i] and resSS[i+K]==resSS[i]:
      resSS[i+K]=0
res=0
for i in resSS:
  res+=i
print(res)


Measured memory_bytes: 4212
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import qualified Data.Array.IO as A
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord

--import qualified Data.IntSet as S
import qualified Data.Sequence as S

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

main :: IO ()
main = do
    s <- getLine :: IO String
    let grS = procPair $ map length (group s)
    --print grS
    let inps = map solveS grS
    --print inps
    putStrLn $ printer $ concat $ zipWith zipper grS inps


printer :: [Int] -> String
printer xs = intercalate " " (map show xs)

zipper :: (Int,Int) -> (Int,Int) -> [Int]
zipper (r,l) (x,y) = replicate (r-1) 0 ++ [x,y] ++ replicate (l-1) 0 


procPair :: [Int] -> [(Int,Int)]
procPair []     = []
procPair [x]    = []
procPair (x:y:xs) = (x,y):(procPair xs)


solveS :: (Int,Int) -> (Int,Int)
solveS (r,l)
    | even (r+l)    = let m = div (r+l) 2
                        in (m,m)
    | r > l && even r = let n = div (r+l) 2 ; m = n+1
                        in (n,m)
    | r > l && odd  r = let n = div (r+l) 2 ; m = n+1
                        in (m,n)
    | r < l && even l = let n = div (r+l) 2 ; m = n+1
                        in (m,n)
    | r < l && odd  l = let n = div (r+l) 2 ; m = n+1
                        in (n,m)



Measured memory_bytes: 7676
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

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

const int INF=1e9;

int main(){
  int n;
  cin>>n;
  
  vector<int> A(n);
  rep(i,n) cin>>A[i];
  
  int tmp1=0,tmp2=0;
  ll cnt=0;
  int l=0;
  rep(i,n){
    cnt++;
    tmp1+=A[i];
    tmp2^=A[i];
    if(tmp1==tmp2) cnt+=i-l;
    else{
      while(l<i){
        tmp1-=A[l];
        tmp2^=A[l];
        l++;
        if(tmp1==tmp2){
          cnt+=i-l;
          break;
        }
      }
    }
  }
  cout<<cnt<<endl;

  return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; i++) cin >> H[i];
    vector<set<int>> v(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        v[a].insert(b);
        v[b].insert(a);
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        bool good = true;
        for (const auto& j : v[i])
            if (H[i] <= H[j]) good = false;
        if (good) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n, m;
    ll sum = 0, ans = 0;
    priority_queue<int, vector<int>, greater<int> > q;
    cin >> n >> m;
    rep(i, n){
        int a;
        cin >> a;
        sum += a;
        q.push(a);
    }
    if(sum > m){
        while(m >= q.top()){
            m -= q.top();
            q.pop();
            ans++;
        }
    }
    else{
        m -= sum;
        ans += n;
        ans += m / q.top();
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:640000000")

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define scanl(a) scanf("%lld",&a)
#define scanii(a,b) scanf("%d%d",&a,&b)
#define scaniii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scanll(a,b) scanf("%lld%lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scani(a) scanf("%d",&a)
#define clr(a) memset(a,0,sizeof(a))
#define clr_(a) memset(a,-1,sizeof(a))
#define pb(a) push_back(a)
#define pii pair<int,int>
#define sqr(a) a*a
#define eps 1e-9
#define inf INT_MAX
#define pi acos(-1.0)
#define ff first
#define ss second
#define INF 1e18
#define endl '\n'
#define vsort(v) sort(v.begin(),v.end())
int A[11][11],num[10];
int calc_parity()
{
    int i=0,j=num[1];
    for(int k=1;k<=4;k++)
    {
        i=A[i][j];
        j=num[k+1];
    }
    return i;
}
bool calc_error()
{
    int i=0,j=num[1];
    for(int k=1;k<=5;k++)
    {
        i=A[i][j];
        j=num[k+1];
    }
    return i==0;
}
bool generate_error()
{
    int f=0;
    for(int i=1;i<=5;i++)
    {
        for(int j=0;j<=9;j++)
        {
            if(j==num[i])continue;
            int x=num[i];
            num[i]=j;
            if(calc_error())
            {
                return true;
            }
            num[i]=x;
        }
        if(f)break;
    }
   // if(f==0)return false;
     for(int i=1;i<=4;i++)
    {
            if(num[i]==num[i+1])continue;
            swap(num[i],num[i+1]);
            if(calc_error())return true;
            swap(num[i],num[i+1]);
    }
    ///cout<<1111111<<endl;
    return false;
}
int main()
{
    /// ios_base::sync_with_stdio(0);
    /// cin.tie(0);
    ///freopen("in.txt","r",stdin);
    ///freopen("out.txt","w",stdout);
    for(int i=0;i<10;i++)
    {
        for(int j=0;j<10;j++)
            scani(A[i][j]);
    }
    int ans=0;
    for(int i=0;i<10000;i++)
    {
        int x=i,j=4;
        while(x>0)
        {
            num[j--]=x%10;
            x/=10;
        }
        while(j!=0)
        {
            num[j--]=0;
        }
        num[5]=calc_parity();
        if(generate_error())ans++;
    }
    printf("%d\n",ans);
    return 0;
}

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

int main(){
    int N, a[100101] = {};
    cin >> N;
    bool dup = false;
    int cnt = 0;
    for(int i = 0; i < N; ++i){
        int in;
        cin >> in; in--;
        if(i == in && dup){
            cnt++;
            dup = false;
        }else if(i == in){
            dup = true;
        }else{
            if(dup) cnt++;
            dup = false;
        }
    }
    if(dup) cnt++;
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
int main(){ 

	for(int i=1;i<=5;i++){
		int x;
		cin>>x;
		if(!x){
			cout<<i<<endl;
			return 0;
		}
	}
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

class RUQ{
public:
  int t[555555],v[555555],k;
  void init(){
    k=1;
    memset(t,0,sizeof(t));
    memset(v,0,sizeof(v));
  }
  void update(int a,int b,int x) {
    v[k]=x;
    update2(a,b,k);
    k++;
  }
  void update2(int a,int b,int x,int k=0,int l=0,int r=1<<18){
    if(b<=l||r<=a)return;
    if(a<=l&&r<=b){t[k]=max(t[k],x);return;}
    int m=(l+r)/2;
    update2(a,b,x,k*2+1,l,m);
    update2(a,b,x,k*2+2,m,r);
  }
  int query(int i){
    i+=(1<<18)-1;
    int res=t[i];
    while(i){
      i=(i-1)/2;
      res=max(res,t[i]);
    }
    return v[res];
  }
};

RUQ tx,ty;

void Main() {
  ll n,T;
  cin >> n >> T;
  ll sum=(n-2)*(n-2);
  tx.init(),ty.init();
  tx.update(0,n,n);
  ty.update(0,n,n);
  ll nx=n,ny=n;
  while(T--) {
    ll z,x;
    cin >> z >> x;
    if(z==1) {
      ll d=tx.query(x);
      sum-=max(0LL,d-2);
      if(x<ny) {
        ny=x;
        ty.update(1,d,ny);
      }
    } else {
      ll d=ty.query(x);
      sum-=max(0LL,d-2);
      if(x<nx) {
        nx=x;
        tx.update(1,d,nx);
      }
    }
  }
  pr(sum);
}

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


Measured memory_bytes: 12300
import java.util.*
 
fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val t = (1..n).map { sc.nextInt() }
    var cur = 1
    var diff = 0
    var ans = 1
    while (cur < n) {
        if (t[cur] == t[cur - 1]) {
            cur++
            continue
        }
        if (t[cur] > t[cur - 1]) {
            if (diff >= 0) {
                diff = 1
            } else {
                ans++
                diff = 0
            }
        } else {
            if (diff <= 0) {
                diff = -1
            } else {
                ans++
                diff = 0
            }
        }
        cur++
    }
    println(ans)
}

Measured memory_bytes: 53788
/*
      author : nishi5451
      created: 12.08.2020 00:28:53
*/

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


int main(){
    string s;
    cin >> s;
    bool flag1 = false;
    rep(i,s.size()){
        if(s[i]=='C' && flag1==false) flag1=true;
        if(flag1==true && s[i]=='F'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int val;

  cin >> val;


  vector<int> kuku(81);

  int k = 0;

  int flag = 0;

  for(int i = 1;i<=9; i++){
    for(int j=1; j<=9; j++){
      kuku.at(k) = i*j;
      k++;
    }
  }

  rep(i,81){
    if(kuku.at(i) == val)
    flag = 1;
  }

  if(flag == 1)
  cout << "Yes";
  else
  cout << "No";



  }


Measured memory_bytes: 3560
N, *AS = $stdin.read.split.map(&:to_i)
h = Hash.new{|h, k| h[k] = 0}
AS.each do |a|
  h[a] += 1
end
p h.map{|k, v|
  if k == v
    # ok
    0
  elsif v < k
    v
  else # v > k
    v - k
  end
}.inject(:+)


Measured memory_bytes: 18812
line = readlines
len = line.length
i = 0

while i < len
    line[i] = line[i].chomp
    i += 1
end

S = line[0]
T = line[1]

ans = 0
for i in 1..3 do
  if S[i-1] == T[i-1] then
    ans += 1
  end
end
  
print ans

Measured memory_bytes: 3836
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N;
int col[210000];
ll a[210000];
vector<int> places[210000];

int main () {
  cin >> N;
  rep(i, N) cin >> col[i];
  rep(i, N) {
    places[col[i]].push_back(i);
  }

  a[0] = 1;

  rep(i, N) {
    int c = col[i];
    a[i] = a[i-1];
    
    int index = lower_bound(All(places[c]), i) - places[c].begin();

    if (index > 0) {
      int j = places[c][index - 1];
      if ((i-j) > 1) {
        a[i] += a[j];
        a[i] %= MOD;
      }
    }
  }

//  rep(i, N) {
//    cout << a[i] << "\n";
//  }

  cout << a[N] << "\n";
}

Measured memory_bytes: 13824
# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()

# int(input())
# map(int, input().split())

n = int(input())

st = set()
for divisor in range(1, int(n ** 0.5) + 1):
    if n % divisor == 0:
        st.add(divisor + (n // divisor) - 2)
print(min(st))


Measured memory_bytes: 40428
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=5050;
//↑templete
int main() {
	int N,K;
	cin>>N>>K;
	int ans=0;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		if(a>=K)
			ans++;
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    map<string, ll> m;
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        string s;
        cin >>s;
        m[s] ++;
    }

    ll ans = 0;
    for(auto it = m.begin(); it != m.end(); it++){
        ans ++;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 19120
-- modules to import --
import Data.ByteString.Char8
import Data.Maybe
import Prelude

-- functions for this task --

read_Integer     = Prelude.fst . Data.Maybe.fromJust . Data.ByteString.Char8.readInteger
read_ListInteger = Prelude.map read_Integer . Data.ByteString.Char8.words

get_Integer     = read_Integer     <$> Data.ByteString.Char8.getLine
get_ListInteger = read_ListInteger <$> Data.ByteString.Char8.getLine

task_B_unit :: Integer -> Integer
task_B_unit target
        | Prelude.even target == True = 1 + (task_B_unit $ div target 2)
        | otherwise                   = 0

task_B :: [Integer] -> Integer
task_B given_list
        | given_list == [] = 10^9
        | otherwise        = Prelude.min (task_B_unit $ Prelude.head given_list) (task_B $ Prelude.tail given_list)


-- main process is below --

main :: IO ()
main = do

        -- STEP.01
        -- read out the given string
        len_sequence <- get_Integer
        val_sequence <- get_ListInteger

        -- STEP.02
        -- output the answer of this task
        Prelude.print $ task_B $ val_sequence

-- End of this source code --

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

int main() {
    
    long long k;
    cin >> k;

    int left = 1;
    int right = 10;

    long long lunlun[100005];
    for(int i=1;i<right;i++)lunlun[i]=i;


    while(true){
        bool ok = false;
        int count = 0;

        vector<long long> temp(right-left);

        //for(int i=left;i<right;i++)temp[i]=lunlun[i];
        for(int i=left;i<right;i++){
            
            if(right + count > k+2){
                ok=true;
                break;
            }

            long long num = lunlun[i];

            if(num%10==0){
                lunlun[right+count]=num*10;
                count++ ;
                lunlun[right+count]=num*10+1;
                count++;
            }else if(num %10 == 9){
                lunlun[right+count]=num*10+8;
                count++;
                lunlun[right+count]=num*10+9;
                count++;
            }else{
                long long mod = num%10;
                lunlun[right+count]=num*10+mod-1;
                count++;
                lunlun[right+count]=num*10+mod;
                count++;
                lunlun[right+count]=num*10+mod+1;
                count++;
            }
        }
        
        if(ok)break;
        left = right;
        right += count;
    }

    //for(int i=0;i<k;i++) printf("%lld\n",lunlun[i]);
    long long ans = lunlun[k];
    cout << ans << endl;
    
}



Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define pb push_back
#define pair pair<int,int>
#define ll long long
#define f first
#define se second
using namespace std;
double pi=acos(-1.0);
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);cout.tie(NULL);
string s;
cin>>s;int count=0;
for(int i=0;i<s.size()/2;i++)
{
  if(s[i]!=s[s.size()-1-i])
  count++;  
}
cout<<count;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 87;

int TC;
int n;

intt a[N];

int main() {

	FAST;

	cin >> n;
	a[0] = 2;
	a[1] = 1;
	for (int i = 2; i <= n; i ++) {
		a[i] = a[i - 1] + a[i - 2];
	}
	cout << a[n] << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a,b,c;
  long long int x,y;
  cin >> a >> b >> c;
  x = a / (b + c) * b;
  y = a % (b + c);
  x += min(y , b);
  cout << x;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const int INF = INT_MAX / 2;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; ++i)
        cin >> v[i];

    vector<vector<int> > a(n, vector<int>(n, -1));
    for(int i=0; i<n; ++i)
        a[i][i] = v[i];
    for(int len=2; len<=n; ++len){
        for(int i=0; i<=n-len; ++i){
            for(int j=i+1; j<i+len; ++j){
                if(a[i][j-1] != -1 && a[i][j-1] == a[j][i+len-1])
                    a[i][i+len-1] = a[i][j-1] * 2;
            }
        }
    }

    vector<int> dp(n+1, INF);
    dp[0] = 0;
    for(int i=0; i<n; ++i){
        for(int j=i; j<n; ++j){
            if(a[i][j] != -1)
                dp[j+1] = min(dp[j+1], dp[i] + 1);
        }
    }
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 1260
#include<stdio.h>
int main(void){
  int a[]={0,1,3,1,2,1,2,1,1,2,1,2,1};
  int x,y;
  scanf("%d %d",&x,&y);
  if(a[x]==a[y]){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
typedef struct{
  int id;
  int left;
  int right;
  int parent;
  int sibling;
}Node;
 
Node *S;
 
int degree(int);
int depth(int);
int height(int);
 
int d = 0;
 
int main(){
  int i, n, id;
  char s[20];
 
  scanf("%d", &n);
 
  S = malloc(sizeof(Node)*n);
 
  //initialize
  for(i = 0; i < n; i++){
    S[i].parent = -1;
    S[i].sibling = -1;
  }
 
  for(i = 0; i < n; i++){
    scanf("%d", &id);
    S[id].id = id;
 
    scanf("%d%d", &S[id].left, &S[id].right);
    S[S[id].left].parent = id;
    S[S[id].right].parent = id;
    S[S[id].left].sibling = S[id].right;
    S[S[id].right].sibling = S[id].left;
  }
 
  for(i = 0; i < n; i++){
    if(S[i].parent == -1) strcpy(s, "root");
    else if(S[i].left == -1 && S[i].right == -1) strcpy(s, "leaf");
    else strcpy(s,"internal node");
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", i, S[i].parent, S[i].sibling, degree(i), depth(i), height(i), s);
    d = 0;
  }
  return 0;
}
 
int degree(int i){
  int deg = 0;
 
  if(S[i].left != -1) deg++;
  if(S[i].right != -1) deg++;
  return deg;
}
 
int depth(int i){
  if(S[i].parent == -1) return d;
  else{
    d++;
    return depth(S[i].parent);
  }
}
 
int height(int i){
  int lef = 0, rig = 0;
 
  if(S[i].left != -1){
    lef++;
    lef += height(S[i].left);
  }
 
  if(S[i].right != -1){
    rig++;
    rig += height(S[i].right);
  }
 
  if(rig >= lef) return rig;
  else return lef;
}

Measured memory_bytes: 600
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let u: usize = scan(tokens);
    let v: usize = scan(tokens);
    let mut t: Graph = Graph::new(n + 1);
    for _ in 0..n - 1 {
        let a: usize = scan(tokens);
        let b: usize = scan(tokens);
        t.add_edge(a, b);
    }
    t.dfs(v, v, 0);
    let du = t.depth[u];
    let mut ans = 0;
    let mut i = u;
    for _ in 0..(du + 1) / 2 {
        ans = std::cmp::max(ans, t.depth[i] + t.height[i]);
        i = t.parent[i];
    }
    ans -= 1;
    println!("{}", ans);
}

#[derive(Debug)]
struct Graph {
    neighbors: Vec<Vec<usize>>,
    visited: Vec<bool>,
    parent: Vec<usize>,
    depth: Vec<usize>,
    height: Vec<usize>,
}

impl Graph {
    fn new(n: usize) -> Graph {
        Graph {
            neighbors: vec![Vec::new(); n],
            visited: vec![false; n],
            parent: vec![0; n],
            depth: vec![0; n],
            height: vec![0; n],
        }
    }
    fn add_edge(&mut self, i: usize, j: usize) {
        self.neighbors[i].push(j);
        self.neighbors[j].push(i);
    }
    fn dfs(&mut self, i: usize, p: usize, d: usize) -> Option<usize> {
        if self.visited[i] {
            return None;
        }
        self.visited[i] = true;
        self.parent[i] = p;
        self.depth[i] = d;
        let mut h = 0;
        for j in self.neighbors[i].clone() {
            if let Some(h1) = self.dfs(j, i, d + 1) {
                h = std::cmp::max(h, h1 + 1)
            }
        }
        self.height[i] = h;
        Some(h)
    }
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
bool graph[110][110];
int h,w;
bool dfs(int x,int y){
    bool ok = false;
    if(x==h-1&&y==w-1&&graph[x][y]) return true;
    if(x+1<h&&graph[x+1][y]){ dfs(x+1,y); ok=true;}
    if(y+1<w&&graph[x+1][y]){ dfs(x+1,y); ok = true; }
    if(!ok){ return false; }
}
int dp[110][110];
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    cin >> h >> w;
    rep(i,0,h){
        string s;
        cin >> s;
        rep(j,0,s.size()){
            if(s[j]=='.') graph[i][j] = true;
            else graph[i][j] = false;
        }
    }
    if(graph[0][0] == false) dp[0][0] = 1;
    else dp[0][0] = 0;
    rep(i,1,h){
        if(graph[i-1][0] && (!graph[i][0])) dp[i][0] = dp[i-1][0]+1;
        else dp[i][0] = dp[i-1][0];
    }
    rep(i,1,w){
        if(graph[0][i-1] && (!graph[0][i])) dp[0][i] = dp[0][i-1]+1;
        else dp[0][i] = dp[0][i-1];
    }
    rep(i,1,h){
        rep(j,1,w){
            dp[i][j] = min(dp[i-1][j]+((graph[i-1][j] && (!graph[i][j])) ? 1:0),
                            dp[i][j-1]+((graph[i][j-1] && (!graph[i][j]))? 1:0));
        }
    }
    cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int t,n,s,f,i,x,a[1000],cnt;
	cnt=0;
	for(i=0;i<1000;i++) a[i]=0;
	while(1){
		cin>>t;
		if(t==0) break;
		cin>>n;
		x=0;
		for(i=0;i<n;i++){
			cin>>s>>f;
			x=x+f-s;
		}
//		if(t-x<=0) cout<<"OK"<<endl;
//		else cout<<t-x<<endl;
		if(t-x<=0){
			a[cnt]=10000;
			cnt=cnt+1;
		}
		else{
			a[cnt]=t-x;
			cnt=cnt+1;
		}
	}
	for(i=0;i<1000;i++){
		if(a[i]==0) break;
		if(a[i]==10000) cout<<"OK"<<endl;
		else cout<<a[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 3100
K = int(input())
lun = list(range(1, 10))
for n in range(K):
    lm = lun[n] % 10
    if lm > 0:
        lun.append(lun[n] * 10 + (lm - 1))
    lun.append(lun[n] * 10 + lm)
    if lm < 9:
        lun.append(lun[n] * 10 + (lm + 1))
print(lun[K-1])

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

const int N = (int) 2e6 + 10 ;
const int inf = (int) 2e9 ;

int main(){
//    freopen("in.txt" , "r" , stdin ) ;
    int a , b ; scanf("%d %d" , &a , &b ) ;
    for( int i = 1 ; i <= 3 ; i++ ) {
        if( (a * b * i) % 2 == 1 ) {
            printf("Yes\n") ;
            return 0 ;
        }
    }
    printf("No\n") ;
    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N;
vector<int> ps;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N;
  for (int i = 2; i <= N; i++) {
    int no = 0;
    for (int j = 2; j*j <= i; j++) {
      if (i % j == 0) no = 1;
    }
    if (!no) ps.push_back(i);
  }
  int ans = 1;
  for (int p : ps) {
    int s = p;
    int sum = 1;
    while (s <= N) {
      sum += N/s;
      s *= p;
    }
    (ans *= sum) %= MOD;
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main(){
    int FH, H, F, X;

    cin >> FH >> H >> F >> X;

    int ans = 0;
    for (int fhi=0; fhi <= FH; fhi++){
        for (int hi=0; hi <= H; hi++){
            for (int fi=0; fi <= F; fi++){
                if (500*fhi+100*hi+50*fi == X) ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
# include <cmath>
# include <cstdio>
using namespace std;
int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	if ((int)abs(a-b) % 2 == 0) printf ("Alice\n");
	else printf("Borys\n");
	return 0;
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int64_t i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int64_t i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const ll md = 1000000007;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N;
    cin >> N;
    map<string, int> M;
    while (N--) {
    	string s;
    	cin >> s;
    	M[s]++;
    }
    cout << "AC x " << M["AC"] << endl;
    cout << "WA x " << M["WA"] << endl;
    cout << "TLE x " << M["TLE"] << endl;
    cout << "RE x " << M["RE"] << endl;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s; cin >> s;

  bool flag = true;
  rep(i,s.size()){
    if(i%2==0 && s[i] == 'L') flag = false;
    if(i%2!=0 && s[i] == 'R') flag = false;
  }  

  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


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

 int main(){
   ll a,b,k;
   cin>>a>>b>>k;
   if(a>k){
     a-=k;
     k=0;
     cout<<a<<" "<<b;
     return 0;
   }else{
     k-=a;
     a=0;
   }
     
     cout<<0<<" "<<max(0ll,b-k);

  }

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define For( i , a ) for(int i=1;i<=a;i++)
#define ort (b+s)/2
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf
#define set multiset

using namespace std;

typedef long long Lint;
typedef double db;
typedef pair<int,int> ii;
typedef pair<int,char> ic;
typedef pair<db,db> dd;
typedef pair<ii,int> iii;
typedef pair<ii,ii> i4;

const int maxn = 100020;
const int maxm = 1000020;
const int MOd = 998244353;

int a, b;
ii ar[maxn];

void solve() {
	scanf("%d %d",&a,&b);
	int cnt = 0;
	for(int i=1;i<=a;i++) {
		scanf("%d",&ar[i].fi), ar[i].se = i;
		if( ar[i].fi >= b ) cnt++;
	}
	printf("%d\n",cnt);
}

int main() {

    //freopen("asd.in","r",stdin);
    //freopen("output17.txt","w",stdout);

	int n = 1;
	//scanf("%d",&n);
	while( n-- ) solve();

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <ctype.h>

void func1(int inp,int *sum_p)
{
	int dt;
	if (isdigit(inp)!=0) {
		sscanf((char*)&inp,"%d",&dt);
		*sum_p += dt;
	}
}


int main()
{
	int  inp;
	int  sum;
	while(1) {
		sum=0;
		inp = getchar();
		if (inp=='0') {
			break;
		}
		func1(inp,&sum);
		while (1) {
			inp = getchar();
			func1(inp,&sum);
			if (inp=='\n') {
				printf("%d\n",sum);
				break;
			}
		}
	}


	return 0;
}

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  int i;
  vector<int> dp(n+1);
  dp[0]=1;
  dp[1]=1;
  rep(i,n-1)dp[i+2]=dp[i+1]+dp[i];
  cout<<dp[n]<<endl;
}


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

int D, N;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> D >> N;
  if (N == 100) {
    if (D == 0) cout << "101" << endl;
    else if (D == 1) cout << "10100" << endl;
    else cout << "1010000" << endl;
  } else {
    cout << N;
    for (int i = 0; i < D; i++) cout << "00";
    cout << endl;
  }

  return 0;
}

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

int main()
{
    char str[4];
    int i,arr[4];
    cin>>str;
    if((str[0]==str[1] && str[1]==str[2]) || (str[1]==str[2] && str[2]==str[3]))
        cout<<"Yes"<<endl;
    else if(str[0]==str[1] && str[1]==str[2] && str[2]==str[3])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 384
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let D: Vec<Vec<usize>> = sc.mat(N, 2);
    let mut cnt = 0;
    for i in 0..N {
        if D[i][0] == D[i][1] {
            cnt += 1;
            if cnt == 3 {
                println!("Yes");
                return;
            }
        } else {
            cnt = 0;
        }
    }
    println!("No");
}


Measured memory_bytes: 2144
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();
        
        if (r - l >= 2018) {
            System.out.println(0);
            return;
        }
        
        int min = 2000000000;
        for (int i = l; i < r; i++) {
            for (int j = l + 1; j <= r; j++) {
                long tmp = ((long)i * j) % 2019;
                int tmp2 = (int)tmp;
                tmp = 1;
                min = Math.min(min, (int)tmp*tmp2);
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 35856
R,G,B,N = map(int,input().split(' '))
A,B,C = sorted([R,G,B])
if A==1 and B==1 and C ==1:
  print(int((N+2)*(N+1)/2))
  exit()
num = 0
E = int(N//C+1)
F = int(N//B+1)
for i in range(E):
  for j in range(F):
    X = N-C*i-B*j
    if X >= 0  and X % A == 0:
      num += 1
print(num)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define LL long long
#define mp make_pair
#define fir first
#define sec second
#define pii pair<LL,LL>
#define MAXN 100010
#define MAXM 200010
#define INF 1e16
using namespace std;
map<pii,LL> ys;
priority_queue<pii,vector<pii>,greater<pii> > pq;
LL SZ;
struct node
{
	LL begin,end,value,next;
}edge[6*MAXM+10];
LL cnt,Head[2*MAXM+MAXN+10],dis[2*MAXM+MAXN+10];
vector<pii> vec[1000010];
LL read()
{
	LL s=0,fh=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')fh=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+(ch-'0');ch=getchar();}
	return s*fh;
}
void addedge(LL bb,LL ee,LL vv)
{
	edge[++cnt].begin=bb;edge[cnt].end=ee;edge[cnt].value=vv;edge[cnt].next=Head[bb];Head[bb]=cnt;
}
void addedge1(LL bb,LL ee,LL vv)
{
	addedge(bb,ee,vv);addedge(ee,bb,vv);
}
void dijkstra(LL start)
{
	LL i,u,v;
	for(i=1;i<=SZ;i++)dis[i]=INF;dis[start]=0LL;
	pq.push(mp(dis[start],start));
	while(!pq.empty())
	{
		u=pq.top().sec;pq.pop();
		for(i=Head[u];i!=-1;i=edge[i].next)
		{
			v=edge[i].end;
			if(dis[v]>dis[u]+edge[i].value)
			{
				dis[v]=dis[u]+edge[i].value;pq.push(mp(dis[v],v));
			}
		}
	}
}
int main()
{
	LL N,M,i,p,q,c,pp,qq,ans,mxc=0;
	N=read();M=read();
	memset(Head,-1,sizeof(Head));cnt=1;
	for(i=1;i<=M;i++)
	{
		p=read();q=read();c=read();
		vec[c].push_back(mp(p,q));mxc=max(mxc,c);
	}
	
	memset(Head,-1,sizeof(Head));cnt=1;
	SZ=N;
	for(c=1;c<=mxc;c++)
	{
		for(vector<pii>::iterator it=vec[c].begin();it!=vec[c].end();it++)
		{
			p=((*it).fir);q=((*it).sec);
			if(ys[mp(c,p)]==0LL)ys[mp(c,p)]=++SZ;
			if(ys[mp(c,q)]==0LL)ys[mp(c,q)]=++SZ;
			pp=ys[mp(c,p)];qq=ys[mp(c,q)];
			addedge1(pp,qq,0LL);
			addedge1(pp,p,1LL);
			addedge1(qq,q,1LL);
		}
	}
	/*
	printf("\n");
	for(i=1;i<=cnt;i++)printf("%lld %lld %lld\n",edge[i].begin,edge[i].end,edge[i].value);
	printf("\n");
	*/
	dijkstra(1);
	
	ans=INF;
	for(c=1;c<=mxc;c++)
	{
		if(ys[mp(c,N)]!=0)ans=min(ans,dis[ys[mp(c,N)]]);
	}
	if(ans==INF){printf("-1");return 0;}
	printf("%lld",(ans-1LL)/2LL+1LL);
	return 0;
}


Measured memory_bytes: 164208
/**********************************************************************
File    .cpp
Author  Takahiro Yamazaki
**********************************************************************/
/**********************************************************************
Include Libraries
**********************************************************************/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)
/**********************************************************************
Declare variables
**********************************************************************/
/**********************************************************************
Declare instance
**********************************************************************/
/**********************************************************************
Proto_type_Declare functions
**********************************************************************/

/**********************************************************************
Main
**********************************************************************/
int main() {
  // string s;
  // cin >> s;
  // int ans = 0;
  // // int n = s.length();
  // // printf("%s\n", s);
  // // int n = stoi(s.c_str()) / 2019;
  // // int n = stol(s.c_str()) / 2019;
  // int n = 110;
  // // printf("%d\n", n);
  // for (int i = 1; i < n+1; i++) {
  //   int tmp = 2019 * i;
  //   if (s.find(std::to_string(tmp)) != s.npos) {
  //     ans++;
  //   }
  // }
  // printf("%d\n", ans);
  string s;
  cin >> s;
  map<ll, ll> mp;
  mp[0] = 1;
  reverse(s.begin(), s.end());
  ll now = 0, sum = 0, ten = 1,a,b;
  each(e, s) {
    // now = (now + (e - '0') * ten) % 2019;
    a = ((e - '0') * ten);
    b = ((e - '0') * ten) % 2019;
    now = (now + b) % 2019;
    // sum = sum + (e - '0') * ten;
    // now = sum % 2019;
    ten *= 10;
    ten %= 2019;
    mp[now]++;
    // cout << ten << ' ' << a << ' '<< b << '\n';
  }
  ll ans = 0;
  each(e, mp) {
    ans += e.second * (e.second - 1) / 2;
  }
  cout << ans << '\n';
  return 0;

}
/**********************************************************************
Functions
**********************************************************************/


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

int main() {
  int n;
  cin >> n;
  double ans = 0;
  for (int i = 0; i < n; i++) {
    double x;
    string u;
    cin >> x >> u;
    if (u == "JPY") {
      ans += x;
    }
    else {
      ans += x*380000;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n, d, x;
    int A[110];
    int sum;

    scanf("%d %d %d", &n, &d, &x);
    for(int i=0; i<n; i++){
        scanf("%d", &A[i]);
    }

    sum = x+n;
    for(int i=0; i<n; i++){
        sum += (d-1)/A[i];
    }

    printf("%d", sum);

    return 0;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  long n, a, b; cin >> n >> a >> b;
  long res = (n / (a + b)) * a;
  n %= (a + b); res += min(n, a); 
  cout << res;
  return 0;
}

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

ll *dp;
ll *a;
/*
ll solution(int s)
{

    if (dp[s] != 0)
    {
        return dp[s];
    }

    dp[s] += min(solution(s+1), (solution(s+2)));
    return dp[s];
}
*/
int main()
{
    int n, t;
    cin >> n;
     a = new ll[ n ];
     dp = new ll[n + 1];
    for(int i=0;i<n;i++){
        cin>>t;
        a[i] = t;
        //cout<<a[i];
    }
    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1] + (abs(a[i-1]-a[i])),dp[i-2] + (abs(a[i-2]-a[i])));
    }
    cout<<dp[n-1]<<endl;
    //dp = new ll[n + 1];
    //cout << solution(1) << endl;

    return 0;
}


Measured memory_bytes: 5136
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b,k=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++){
		int s=0,d=i;
		for(int j=1;;j++){
			s+=d%10;
			d/=10;
			if(d==0)break;
		}
		if(s>=a&&s<=b){
			k+=i;
		}
	} 
	cout<<k<<endl;   
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
struct UnionFind{
  vector<int> par;
  vector<int> sizes;
  UnionFind(int n) : par(n), sizes(n, 1) {
    rep(i,n) par[i] = i;
  }
  int root(int x) {
    if (x == par[x]) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
	}
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return sizes[root(x)];
  }
};
int main(){
	int H,W;
	char S[404][404];
	ll bnum[200000]={},wnum[200000]={};
	ll ans=0;
	scan(H);scan(W);
	UnionFind uf(H*W);
	rep(i,H){
		scan(S[i]);
	}
	rep(i,H){
		rep(j,W){
			if(i!=H-1){
				if(S[i][j]=='#'&&S[i+1][j]=='.'){
					uf.unite(i*W+j,(i+1)*W+j);
				}
				else if(S[i][j]=='.'&&S[i+1][j]=='#'){
					uf.unite(i*W+j,(i+1)*W+j);
				}
			}
			if(j!=W-1){
				if(S[i][j]=='#'&&S[i][j+1]=='.'){
					uf.unite(i*W+j,i*W+j+1);
				}
				else if(S[i][j]=='.'&&S[i][j+1]=='#'){
					uf.unite(i*W+j,i*W+j+1);
				}
			}
		}
	}
	rep(i,H){
		rep(j,W){
			if(S[i][j]=='#'){
				bnum[uf.root(i*W+j)]++;
			}
			else{
				wnum[uf.root(i*W+j)]++;
			}
		}
	}
	rep(i,H){
		rep(j,W){
			if(uf.root(i*W+j)==i*W+j){
				ans+=bnum[i*W+j]*wnum[i*W+j];
			}
			//printf("i*W+j:%d  root:%d  bnum:%d wnum:%d\n",i*W+j,uf.root(i*W+j),bnum[i*W+j],wnum[i*W+j]);
		}
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 4736