akhauriyash/Code-Regression huggingface dataset:
Option Infer On
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim a As Integer() = New Integer(N - 1) {}

        For i = 0 To N - 1
            a(i) = NextInt()
        Next

        Dim j As Integer = 1
        Dim dic As New Dictionary(Of Integer, Boolean)

        For i = 1 To N
            dic(j) = True
            j = a(j - 1)
            If dic.ContainsKey(j) Then
                Exit For
            ElseIf j = 2 Then
                WriteLine(i)
                Exit Sub
            End If
        Next

        WriteLine(-1)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 29812
N= int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

result = 0
for i in range(N):
    result += B[A[i]-1]
    if i>=1:
        if A[i] == A[i-1]+1:
            result += C[ A[i-1]-1 ]
print(result)

Measured memory_bytes: 3064
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll P[200010];
    rep(i,0,N) cin >> P[i];
    ll ans = 0;
    ll min_val = INF;
    rep(i,0,N){
        if(min_val > P[i]){
            ans++;
            min_val = P[i];
        }
    }
    print(ans);
    

}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  ll n,a[100000];
  ll pos[100000],neg[100000];
  ll pans=0,nans=0;
  cin>>n;
  rep(i,n){
    cin>>a[i];
  }
  if(a[0]>0){neg[0]=-1;pos[0]=a[0];nans+=abs(a[0])+1;}
  else if(a[0]==0){pos[0]=1;neg[0]=-1;pans=nans=1;}
  else{pos[0]=1;neg[0]=a[0];pans+=abs(a[0])+1;}
  //cout<<neg[0]<<" "<<pos[0]<<endl;
  repi(i,1,n){
    neg[i]=neg[i-1]+a[i];
    pos[i]=pos[i-1]+a[i];
   
    if(i%2==0){
      if(neg[i]>=0){nans+=abs(neg[i])+1;neg[i]=-1;}
      if(pos[i]<=0){pans+=abs(pos[i])+1;pos[i]=1;}
    }
    else{
      if(neg[i]<=0){nans+=abs(neg[i])+1;neg[i]=1;}
      if(pos[i]>=0){pans+=abs(pos[i])+1;pos[i]=-1;}
    }
    // cout<<neg[i]<<" "<<pos[i]<<" "<<nans<<" "<<pans<<endl;
  }
  cout<<min(pans,nans)<<endl;
  return 0;
}





Measured memory_bytes: 2560
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

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

    ll N, X, T;
    cin >> N >> X >> T;
    cout << (N / X) * T + (N % X == 0 ? 0 : 1) * T << endl;
}

Measured memory_bytes: 3608
#include<stdio.h>
int main (){
    long H,W,Ans;
    scanf("%ld%ld",&H,&W);
    if(H==1||W==1){
        Ans=1;
    }else if((H*W)%2==1){
        Ans=H*W/2+1;
    }else{
        Ans=H*W/2;
    }
    printf("%ld",Ans);
    return 0;
}

Measured memory_bytes: 128
#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() {
    ll H, W;
    cin >> H >> W;
    if (H == 1 || W == 1) cout << 1 << endl;
    else if (H * W % 2 == 0) cout << H * W / 2 << endl;
    else cout << (H * W + 1) / 2 << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a) for(auto i=0; i<a; i++)
#define rep1(i, a, b) for(auto i=a; i<b; i++)
#define p_b push_back
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;

int main() {
    string a, b;
	cin>>a>>b;
	vi v1(30, -1), v2(30, -1);
	rep(i, a.length()){
		if(v1[b[i]-'a']==-1){
			v1[b[i] - 'a'] = a[i] - 'a';
		}
		if(v1[b[i] - 'a'] != a[i] - 'a'){
			cout<<"No";
			return 0;
		}
		if(v2[a[i]-'a']==-1){
			v2[a[i] - 'a'] = b[i] - 'a';
		}
		if(v2[a[i] - 'a'] != b[i] - 'a'){
			cout<<"No";
			return 0;
		}
		// cout<<a[i]<<" " <<b[i]<<endl;
	}
	cout<<"Yes";
    return 0;
}


Measured memory_bytes: 776
# coding: utf-8

S = input()
odd = []
even = []
result = 'No'

S_list = list(S)

for i, s in enumerate(S_list):
    if (i + 1) % 2 == 0:
        even.append(s)
    else:
        odd.append(s)

if 'L' not in odd and 'R' not in even:
    result = 'Yes'

print(result)

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl;
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

// Aliases
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    while(true) {
        int n;
        cin >> n;
        if(n == 0) break;
        int sum = 0, smn = INT_MAX, smx = INT_MIN;
        REP(i, n) {
            int s;
            cin >> s;
            sum += s;
            smn = min(smn, s);
            smx = max(smx, s);
        }
        cout << (sum - smn - smx) / (n - 2) << "\n";
    }

    return 0;
}



Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, K; cin >> N >> K;
    string s; cin >> s;
    s = '1'+ s + '1';

    vector<pair<int, int>> v;
    v.push_back({0, 0});
    bool zero = false;

    int left, right;
    for(int i=1; i<=N+1; i++){
        if(zero == false && s[i] == '0'){
            zero = true;
            left = i;
        }
        else if(zero == true && s[i] == '1'){
            zero = false;
            right = i-1;
            v.push_back({left, right});
        }
    }

    v.push_back({N+1, N+1});

    if(v.size()-2 <= K){
        cout << N << endl;
        return 0;
    }

    int ans = 0;
    int size = v.size()-2;
    for(int i=1; i<=size+1-K; i++) ans = max(ans, v[i+K].first - v[i-1].second - 1);

    cout << ans << endl;
}

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

using namespace std;

const int N = 1e5 + 5;

typedef long long ll;

const ll mod = 1e9 + 7;

int n, a, b;

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> a >> b;
    if (a < b) {
        if ((b - a - 1) % 2) {
            cout << "Alice";
        } else {
            cout << "Borys";
        }
        return 0;
    }
    if ((a - b - 1) % 2)
        cout << "Alice";
    else
        cout << "Borys";
}


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

int main(int argc, char *argv[]){
  int N;
  cin>>N;
  vector<int> L(N);
  int l;
  for(int i=0; i<N; i++){
    cin>>l;
    L[i]=l;
  }
  sort(L.begin(),L.end(),greater<int>());
  int count=0;
  int a,b,c;
  for(int i=0; i<N; i++){
    if(N-i==1) break;
    a=L[i];
    for(int j=i+1; j<N; j++){
      b=L[j];
      for(int k=j+1; k<N; k++){
	c=L[k];
	if(a<b+c) count++;
	else      break;
      }
    }
  }
  cout<<count<<endl;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <numeric>

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  std::vector<intmax_t> x(N), y(N), z(N);
  for (size_t i = 0; i < N; ++i)
    scanf("%jd %jd %jd", &x[i], &y[i], &z[i]);

  intmax_t res = 0;
  for (int i = 0; i < 8; ++i) {
    std::vector<intmax_t> xyz(N);
    for (size_t j = 0; j < N; ++j) {
      intmax_t& cur = xyz[j];
      cur += ((i & 4)? x[j]:-x[j]);
      cur += ((i & 2)? y[j]:-y[j]);
      cur += ((i & 1)? z[j]:-z[j]);
    }
    std::sort(xyz.rbegin(), xyz.rend());
    res = std::max(res, std::accumulate(xyz.begin(), xyz.begin()+M, 0L));
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define ull unsigned long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ff first
#define ss second
#define fast ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
#define nl "\n"
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define fl(a,x) memset(a,x,sizeof(a));
#define pt(a,x) cout << get<x>(a) << " " ;
#define mt make_tuple
#define vec vector

#define int long long

const int mod = (int) 1e9 + 7 ;
const int MOD = (int) 998244353 ;
const int INF = (int) 1e18 ;

typedef vector<int> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef vector<vector<int> > vv;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}


void solve() {
	int n; cin >> n;
	string s="ACL"; 

	rep(i,0,n) cout << s; 

}

int32_t main() {

#ifdef LOCAL
    freopen("error.txt", "w", stderr);
#endif

    fast;

	// int t; cin >> t; while(t--)
		solve() ;

	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3648
N = int(input())

c = [[0]*10 for _ in range(10)]

for k in range(1,N+1):
    c[int(str(k)[0])][int(str(k)[-1])]+=1

ans = 0

for k in range(81):
    i = k // 9 + 1
    j = k % 9 + 1
    ans += c[i][j] * c[j][i]

print(ans)



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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.at(i) = a;
  }
  int sum = 1;
  int x = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(x) == 2) {
      cout << sum << endl;
      break;
    }
    else {
      sum += 1;
      x = A.at(x)-1;
    }
    if (i == N-1) {
      cout << -1 << endl;
    } 
  }
}
      

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

int main(){
    int n; cin >> n;
    rep(i,n+1){
        if(1.08*i >= n && 1.08*i < n+1){
            cout << i << "\n";
            return 0;
        }
    }
    cout << ":(" << endl;
}

Measured memory_bytes: 256
input_s = input()
lengthOfInputS =len(input_s)

listOfLower_abc = list( map(chr, range(97,97+26)) ) # abcd...xyz

# 連続する2文字 もしくは、一つ飛ばしの同じ文字がなければ、
# アンバランスでない

# 連続する2文字が存在するか
for lower_abc in listOfLower_abc:
	double_abc = lower_abc*2
	if double_abc in input_s:
		indexOfCh = input_s.index( double_abc )
		print( indexOfCh+1, indexOfCh+2 )
		exit()

# 一つ飛ばしの同じ文字が存在するか
for i in range( lengthOfInputS-2 ):
	if input_s[i] == input_s[i+2]:
		print( i+1, i+3 )	
		exit()

print( "-1 -1" )


Measured memory_bytes: 3188
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<stdio.h>
using namespace std;
int main() {
	int a[200000], b[200000];
	char op[200000];	
	int last;
	for(int i=0;i<200000;i++) {
		cin >> a[i] >> op[i] >> b[i];
		if (op[i] == '?') {
			last = i;
			break;
		}
	}
	for (int i = 0; i < last; i++) {
		if (op[i] == '+')
			cout << a[i] + b[i] << endl;
		else if (op[i] == '-')
			cout << a[i] - b[i] << endl;
		else if (op[i] == '*')
			cout << a[i] * b[i] << endl;
		else if (op[i] == '/')
			cout << a[i] / b[i] << endl;
	}


	return 0;
}


Measured memory_bytes: 3096
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;
        public static void Main()
        {

            var args = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            var start = args[0] * 60 + args[1];
            var end = args[2] * 60 + args[3];

            if (end - (start + args[4]) <= 0) Console.WriteLine(0);
            else Console.WriteLine(end - (start + args[4]));

        }

    }

}

Measured memory_bytes: 28296
// ---------- BEG ../defs.hpp BEG ----------
#ifndef atcoder_defs_hpp
#define atcoder_defs_hpp
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;
using i8t = std::int64_t;
using u8t = std::uint64_t;
using vi8t = std::vector<i8t>;
using vvi8t = std::vector<std::vector<i8t>>;
using vu8t = std::vector<u8t>;
#include <limits>
static const i8t i8t_max=numeric_limits<i8t>::max();
static const i8t i8t_min=numeric_limits<i8t>::min();
#include <unordered_map>
#include <unordered_set>
template<typename Key,typename Value> using map_t=std::unordered_map<Key, Value>;
template<typename Key> using set_t=std::unordered_set<Key>;
#define F3(i,i0,iN,step) for(i8t i=i0,i##_N=iN;i<i##_N;i+=step)
#define F2(i,i0,iN) F3(i,i0,iN,1)
#define F(i,N) F3(i,0,N,1)
#define FR(i,N) for(i8t i=N;i--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
template<typename T> T umax(T& ans,T const& value) {if(value>ans)ans=value;return ans;}
template<typename T> T umin(T& ans,T const& value) {if(value<ans)ans=value;return ans;}
template<typename T> struct identity { using type = T; };
#endif
// ---------- END ../defs.hpp END ----------

int main() {
  R(N)RV(A,N);

  vi8t H(N,0);
  F(i,N)H[A[i]-1]++;

  i8t s=0;
  F(a,N)s+=H[a]*(H[a]-1)/2;

  F(i,N)P(s-(H[A[i]-1]-1));
  return 0;
}


Measured memory_bytes: 5872
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

h,n = map(int, input().split())
a = list(map(int, input().split()))

ans = 'No'
total = 0
for i in range(n):
    total += a[i]
    if total >= h:
        ans = 'Yes'
        break
print(ans)




Measured memory_bytes: 20440
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

int main() {
   ll x;
   cin >> x;
   ll ans = x / 11;
   ans *= 2;
   ll tmp = x % 11;
   if (tmp != 0) {
      if (tmp <= 6) ans += 1;
      else ans += 2;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <set>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

typedef long long ll;

using namespace std;

int main(void) {
  int a, b, c; cin >> a >> b >> c;
  int s = a + b + c;
  int m = max(a, max(b, c));
  int count = 0;
  if (s % 2 == (3 * m) % 2) {
    count = (3 * m - s) / 2;
  } else {
    count = (3 * m + 3 - s) / 2;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>
#include <utility>
#include <map>
#include <functional>
#include <initializer_list>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
using namespace std;
typedef long long ll;

ll row(ll a, ll b, ll MOD){
    ll val = 1;
    for(int i=0; i<b; i++){
        val *= a%MOD;
        val = val%MOD;
        }
    return val%MOD;
    }


int main(){
    ll MOD=998244353;
    ll N;
    cin >> N;
    vector<ll> D(N);
    for(int i=0; i<N; i++){
        cin >> D[i];
        }
    if(D[0]!=0) cout << 0;
    else{
        sort(D.begin(), D.end());
        if(D[1]==0)cout << 0;
        else{
            ll Count=1;
            vector<ll> C(D[N-1]+1);
            for(int i=0; i<N; i++){
                C[D[i]]++;
                }
            for(int i=1; i<D[N-1]+1; i++){
//                cout << row(C[i-1], C[i]) << endl;
                Count *= row(C[i-1], C[i], MOD);
//                cout << Count ;
                Count = Count%MOD;
                }
            cout << Count;
            }
        }
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N, A, B;
    string S;
    cin >> N >> A >> B >> S;
    int a = 0, b = 0;
    REP(i, N) {
        if (S[i] == 'a') {
            if (a + b < A + B) {
                cout << "Yes" << endl;
                a++;
                continue;
            }
        } else if (S[i] == 'b') {
            if (a + b < A + B && b < B) {
                cout << "Yes" << endl;
                b++;
                continue;
            }
        }
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 848
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String l1 = r.readLine();

		if (l1.charAt(0) != l1.charAt(1) || l1.charAt(1) != l1.charAt(2)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		r.close();
	}
}

Measured memory_bytes: 24532
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	for (;;) {
		int m, f, r; cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) break;
		char c;
		if (m == -1 || f == -1) c = 'F';
		else if (m + f >= 80) c = 'A';
		else if (m + f >= 65) c = 'B';
		else if (m + f >= 50) c = 'C';
		else if (m + f >= 30 && r >= 50) c = 'C';
		else if (m + f >= 30) c = 'D';
		else c = 'F';
		cout << c << endl;
	}
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;

int main() {
    int N;
    ll X[100001];
    cin >> N;
    rep(i, N){
        cin >> X[i];
    }
    X[N] = 0;

    ll ret = 0;
    rep(i, N){

        // fprintf(stderr, "%d %d -> ", X[i], X[i+1]);
        ll x1 = X[i] / 2;
        X[i] -= x1 * 2;
        ll x2 = min(X[i], X[i+1]);
        X[i] -= x2;
        X[i+1] -= x2;

        ret += x1;
        ret += x2;

        // fprintf(stderr, "%d %d x1:%d x2:%d\n", X[i], X[i+1], x1, x2);
    }

    cout << ret << endl;

}

Measured memory_bytes: 1024
#include <stdio.h>

constexpr const char* table[] = { "Sunny", "Cloudy", "Rainy" };

int main()
{
	char ch[7];
	scanf("%s", ch);

	if (*ch == 'S')
		printf("%s\n", table[1]);
	else if (*ch == 'C')
		printf("%s\n", table[2]);
	else
		printf("%s\n", table[0]);
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <map>
#include <cmath>
#include <bitset>
#include <string>

using namespace std;

#define int long long

signed main() {
    int n, k;   
    cin >> n >> k;

    int r = n % k;
    
    cout << min(r, k - r) << endl;;
    return 0;
}

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


int func(int ip){
	int temp=0;
	while(ip>0){
	temp += ip%10;
	ip =ip/10;
	}
	return temp;
}

int main(){
int N,A,B;
	int sum=0;
	cin>>N>>A>>B;
	for(int i = 0;i<=N;i++)
	{
		if(A<=func(i) && func(i)<=B)
		{
		sum +=i;
		}
	}

 cout<<sum<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = Console.ReadLine().Trim();
            string sT = Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "NO";
            if (sS.Reverse().SequenceEqual(sT)) { sOut = "YES"; }               // 文字列反転

            // 出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

int main(){
    int a, b;
    cin >> a >> b;
    int c = max(a, b);
    if (a == b) {
        cout << a * 2 << "\n";
    }
    else {
        cout << c * 2 - 1 << "\n";
    }
    
}

Measured memory_bytes: 256
//Created by Kira

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

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
    IOS

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

    //a + b = X, 2a + 4b = Y
    //2 * b = y - 2 * x


    int b = y - 2 * x;

    if(b < 0){
        cout<<"No";
        return 0;
    }

    if(b & 1)cout<<"No";
    else{
        b /= 2;
        if(x - b >= 0)cout<<"Yes";
        else cout<<"No";
    }



}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1) res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



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

int main(){
	int a,b,c,k,ans=0;
	cin >> a >> b >> c >> k;
	while(1){
		if(a<=k) {
			ans+=a;
			k-=a;
			break;
		}
		else if(a>k) {
			ans+=k;
			cout << ans << "\n";
			return 0;
		}
	}
	while(1){
		if(b<=k){
			k-=b;
			if(k==0) {
				cout << ans << "\n";
				return 0;
			}
			break;
		}
		else if(b>k){
			cout << ans << "\n";
			return 0;
		}
	}
	while(1){
		if(c<=k){
			ans-=c;
			cout << ans << "\n";
			return 0;
		}
		else if(c>k){
			ans-=k;
			cout << ans << "\n";
			return 0;
		}
	}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

const int mod = 1000000007;

int a(vector<int> &dp, int S) {
  if(S <= 2) return 0;
  if(S <= 5) return 1;
  if(dp[S] >= 0) return dp[S];
  int ans = 0;
  for(int i=3; i<S; i++) {
    ans += a(dp, S-i);
    ans %= mod;
  }
  ans++;
  dp[S] = ans;
  return ans;
}


signed main() {
  int S; cin >> S;
  vector<int> dp(S+1, -1);
  
  if(S <= 2) {
    cout << 0 << endl;
    return 0;
  }
  if(S <= 5) {
    cout << 1 << endl;
    return 0;
  }

  
  dp[3] = 1;
  dp[4] = 1;
  dp[5] = 1;
  
  
  
  cout << a(dp, S) << endl;
    
  

}


Measured memory_bytes: 3656
#include<iostream>

using namespace std;

int n, m;
int taro[100], hanako[100]; 
int change_taro=0, change_hanako=0;

void set_score(){
    for(int i=0; i<n; i++){
        cin >> taro[i];
    }
    for(int i=0; i<m; i++){
        cin >> hanako[i];
    }
}

void sort_taro(){
    int bucket[101] = {0};


    for(int i = 0; i < n; i++){
        bucket[taro[i]]++;
    }

    for(int i=0,k=0; i < 101;i++){
        for(int j=0; j<bucket[i]; j++){
            taro[k++] = i;
        }
    }
}

void sort_hanako(){
    int bucket[101] = {0};


    for(int i = 0; i < m; i++){
        bucket[hanako[i]]++;
    }

    for(int i=0,k=0; i < 101;i++){
        for(int j=0; j<bucket[i]; j++){
            hanako[k++] = i;
        }
    }
}

int change(int i, int j){
    int temp[1] = {0};
    int taro2[100] = {0};
    int hanako2[100] = {0};
    int sum_taro = 0, sum_hanako = 0;

    for(int a=0; a<n; a++){
        taro2[a] = taro[a];
    }
    for(int b=0; b<m; b++){
        hanako2[b] = hanako[b];
    }


    temp[0] = taro2[i];
    taro2[i] = hanako2[j];
    hanako2[j] = temp[0];

    for(int c=0; c<n; c++){
        sum_taro += taro2[c];
    }

    for(int d=0; d < m; d++){
        sum_hanako += hanako2[d];
    }


    if(sum_taro == sum_hanako){
        change_taro = taro[i];
        change_hanako = hanako[j];
        return 1;
    }

    return 0;
}

void match_total(){

    int dec = 0;

    for(int i=0; i < n; i++){
        for(int j=0; j < m; j++){
            dec = change(i,j);
            if(dec == 1){
                break;
            }
        }
        if(dec == 1){
            break;
        }
    }

    if(dec == 1){
        cout << change_taro << " " << change_hanako << endl;
    }else{
        cout << -1 << endl;
    }
}

int main(){
    while(1){
        cin >> n >> m;
        if(n == 0 && m == 0){
            break;
        }
        set_score();
        sort_taro();
        sort_hanako();
        match_total();
    }

    return 0;
}


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

// semi-open   Range minimum query

struct RSQ{
  int n=(1<<17),data[(1<<18)];
  RSQ(){
    memset(data,0,sizeof(data));
  }
  void add(int i,int v){
    while(i<=n){
      data[i]+=v;
      i+=i&-i;
    }
  }
  int sum(int i){
    int res=0;
    while(i>0){
      res+=data[i];
      i-=i&-i;
    }
    return res;
  }
  //[a,b)
  int sum(int x,int y){
    return sum(y-1)-sum(x-1);
  }
};


int main(){
  RSQ a;
  int c,x,y,n,q;
  cin>>n>>q;
  for(int i=0;i<q;i++){
    scanf("%d%d%d",&c,&x,&y);
    if(c)cout<<a.sum(x,y+1)<<endl;
    else a.add(x,y);
  }
}


Measured memory_bytes: 4244
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		if(a <= b)
		{
			if(b <= c)
			{
				System.out.println(a+b);
			}
			else
			{
				System.out.println(a+c);
			}
		}
		else
		{
			if(a <= c)
			{
				System.out.println(a+b);
			}
			else
			{
				System.out.println(b+c);
			}
		}

	}

}


Measured memory_bytes: 35604
N = int(input())
A = [int(x) for x in input().split()]
numberdict = dict()
for i in range(N):
    if A[i] in numberdict:
        numberdict[A[i]] += 1
    else:
        numberdict[A[i]] = 1
ans = 0
for j in numberdict.keys():
    if numberdict[j] >= j:
        ans += numberdict[j] - j
    else:
        ans += numberdict[j]
print(ans)


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

int main(){
	int S,h,m,s;
	cin>>S;
	h=S/3600;
	m=(S-h*3600)/60;
	s=S-h*3600-m*60;
	cout<<h<<":"<<m<<":"<<s<<endl;
	

  return 0;
}



Measured memory_bytes: 3096
#include<iostream>

#include<string>

using namespace std;

int main(){
  int A;
  int B;

  while(cin>>A>>B,A||B){
    if(A<=B){
      cout<<A<<" "<<B<<endl;
    }
    if(A>B){
      cout<<B<<" "<<A<<endl;
    }
  }

    return 0;
}



Measured memory_bytes: 2988
#include <iostream>
#include <fstream>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <cassert>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <list>
#include <forward_list>
#include <array>
#include <cstring>
#include <cmath>
#include <tuple>
#include <complex>
#include <bitset>
#include <climits>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using LD = long double;
using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pld = pair<LD, LD>;
const int MAX_N = 1e5;
bitset<MAX_N + 1> ist_nicht_gut;


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

    int N, M;
    cin >> N >> M;
    vector<int> elev(N + 1);
    for (int i = 1; i <= N; ++i)
    {
        cin >> elev[i];
    }
    vector<vector<int>> adj(N + 1);
    while (M--)
    {
        int i, j;
        cin >> i >> j;

        adj[i].emplace_back(j);
        adj[j].emplace_back(i);
    }

    for (int obs = 1; obs <= N; ++obs)
    {
        for (const int adj_obs : adj[obs])
        {
            if (elev[adj_obs] >= elev[obs])
            {
                ist_nicht_gut[obs] = true;
                // break;
            }
        }
    }

    cout << N - ist_nicht_gut.count();
}


Measured memory_bytes: 8732
using System;

class B
{
	static void Main()
	{
		var h = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
		var g = Gcd(h[0], h[1]);
		Console.WriteLine(g * 3 * (h[0] / g - 1));
	}

	static long Gcd(long x, long y) { for (long r; (r = x % y) > 0; x = y, y = r) ; return y; }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        while (n > 0) {
            int x = 0;
            int y = 0;
            int z = 0;
            int p[] = new int[n];
            int d[] = new int[n];
            int e[] = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = scanner.nextInt();
                d[i] = scanner.nextInt();
                e[i] = scanner.nextInt();
            }
            for (int i = 0; i < n; i++) {
                x = d[i] + e[i];
                if (y < x) {
                    y = x;
                    z = p[i];
                }

            }

            System.out.print(z+" ");
            System.out.println(y);

            n = scanner.nextInt();

        }
    }
}



Measured memory_bytes: 162024
N,X,Y=gets.split.map(&:to_i)
G=Array.new(N){Array.new}
N.times do |v|
  G[v]<<v+1 if v+1<N
  G[v]<<v-1 if 0<=v-1
  G[v]<<Y-1 if v==X-1
  G[v]<<X-1 if v==Y-1
end
s=[0]*N
N.times do |x|
  q=[x]
  d=[]
  d[x]=0
  until q.empty?
    u=q.shift
    G[u].each do |v|
      next if d[v]
      d[v]=d[u]+1
      s[d[v]]+=1
      q<<v
    end
  end
end
p *s[1...N].map{|i|i/2}


Measured memory_bytes: 52108
n = int(input())
l = {
  'AC': 0,
  'WA': 0,
  'TLE': 0,
  'RE': 0
}

for _ in range(n):
  s = input()
  l[s] += 1

print('AC x %d' % (l['AC']))
print('WA x %d' % (l['WA']))
print('TLE x %d' % (l['TLE']))
print('RE x %d' % (l['RE']))


Measured memory_bytes: 69840
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll modpow(ll x, ll n, ll mod){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % mod;
        mul = mul * mul % mod;
        n /= 2;
    }
    return res;
}


ll calc(ll a, ll cnt){
    if (a == 0) return cnt;
    ll c = __builtin_popcount(a);
    return calc(a%c, cnt+1);
}


ll count(string a, ll q){
    ll ret = 0;
    int m = a.size();
    rep(i, m) if (a[i] == '1') {
        ret += modpow(2, m-i-1, q);
        // cout << "mp: " << modpow(2, m-i-1, q) << endl;
    }
    return ret % q;
}

int main(){
    int n;
    cin >> n;
    string x;
    cin >> x;
    int p = 0;
    rep(i, n) p += (x[i] == '1');

    ll t = count(x, p+1);

    if (p == 1){// 例外処理
        ll c;
        rep(i, n){
            if (x[i] == '0') {
                c = t;
                c += modpow(2, n-i-1, p+1);
                c %= p+1;
                cout << calc(c, 1) << endl;
            }
            else cout << 0 << endl;
        }
        return 0;
    }
    
    ll s = count(x, p-1);

    rep(i, n){
        ll c;
        if (x[i] == '1'){
            c = s+p-1;
            c -= modpow(2, n-i-1, p-1);
            c %= p-1;
        }
        else{
            c = t;
            c += modpow(2, n-i-1, p+1);
            c %= p+1;
        }
        cout << calc(c, 1) << endl;
    }

    return 0;
}


Measured memory_bytes: 3860
import java.util.Scanner;

public class Main {
    //Bounding
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), x = sc.nextInt();
        int[] L = new int[n];
        for (int i = 0; i < n; i++) L[i] = sc.nextInt();
        int d = 0, index = 1;
        while (d < x && index <= n) {
            d = d + L[index - 1];
            index++;
        }
        if (d <= x) System.out.println(index);
        else System.out.println(index - 1);
    }
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace std;
#define int long long int
#define double long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> new_data_set;
bool isprime(int n)
	{
    	if(n==1) return true;
    	for(int i = 2;i*i<=n;i++){
    		if(n%i==0) return false;
		}
		return true;
	}
int lcm(int a,int b){
	return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0){
    	return a;
	} 
    return gcd(b, a % b);  
      
} 
unsigned int factorial(unsigned int n) 
{ 
    if (n == 0) 
    return 1; 
    return n * factorial(n - 1); 
} 
const int inf=1e17+7;
int dsu[1000001],s[100005];
pair<int,int>pz[100001],po[100001];
void init(int n,int m){
	for(int i=1;i<=n;i++){
		dsu[i]=i;
		s[i]=1;
	}
}
int root(int x){
	while(dsu[x]!=x){
		x = dsu[x];
	}
	return x;
}
void uni(int x,int y){
	int p = root(x);
	int q = root(y);
	if(p==q){
		return;
	}
	else{
		if(s[p]<s[q]){
			s[q]+=s[p];
			dsu[p] = q;
		}
		else{
			s[p]+=s[q];
			dsu[q] = p;
		}
	}
}
int power(int x, unsigned int y)  
{  
    int res = 1;
    x = x ; 
    if (x == 0) return 0;  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x);   
        y = y>>1;  
        x = (x*x);  
    }  
    return res;  
}
bool visited[100001]={false};

//void dfs(int x){
//	visited[x]=true;
//	//ans.push_back(x);
//	//c[x]=1;
//	for(auto &child:graph[x]){
//		if(!visited[child]){
//			dfs(child);	
//			//c[x]+=c[child];
//		}
//	}
//}
signed main(){
	FAST
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)cin>>arr[i];
	int dp[n];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i]),dp[i-2]+abs(arr[i-2]-arr[i]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int W,H,N;cin >> W >> H >> N;
  int w=0,h=0;
  rep(i,N){
    int x,y,a;cin >> x >> y >> a;
    if(a==1)w = max(w,x);
    if(a==2)W = min(W,x);
    if(a==3)h = max(h,y);
    if(a==4)H = min(H,y);
  }
  cout << max(0,W-w)*max(0,H-h) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	char x;
	scanf("%c",&x);
	if(x=='a' || x=='e' || x=='i' || x=='o' || x=='u'){
		printf("vowel\n");
	}
	else{
		printf("consonant\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
int i,j,n,m,minn,maxx,tmp,q,t;
const int N=2e5+5;
int a[N];
int f[N];
int d[N];

int main(){
    ios::sync_with_stdio(false);
    int m,d;
    cin>>m>>d;
    int cnt=0;
    for(int i=22;i<=d;i++){
        int s=i%10;
        if(s<2)continue;
        int t=i/10;
        if(s*t<=m&&s*t>=1){
               // cout<<i<<endl;
                cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  vector<int> vec(3) ;
  rep(i, 3){
    cin >> vec.at(i) ;
  }
  sort(vec.begin(),vec.end()) ;
  
  cout <<vec.at(0)+vec.at(1)<<endl ;
  
    return 0 ;
}

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int i, n;
  int C[VMAX];

  scanf("%d", &n);

  A = (unsigned short *)malloc(sizeof(short) * n + 1);
  B = (unsigned short *)malloc(sizeof(short) * n + 1);

  for (i=0; i<= VMAX; i++) C[i] = 0;

  for (i=0; i<n; i++){
    scanf("%hu", &A[i+1]);
    C[A[i+1]]++;
  }

  for (i=1; i<=VMAX; i++) C[i] = C[i] + C[i-1];

  for (i=1; i<=n; i++){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }

  for (i=1; i<=n; i++){
    if (i > 1) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}



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

int main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<int>> A(H, vector<int>(W));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> A[i][j];
		}
	}
	int res = 1e9;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int sum = 0;
			for (int x = 0; x < H; x++) {
				for (int y = 0; y < W; y++) {
					sum += min(abs(i - x), abs(j - y)) * A[x][y];
				}
			}
			res = min(res, sum);
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 3164
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 前準備 100000以下の素数取得+100003も
            List<int> lstPrim = GetPrim();

            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iX = int.Parse(sS[0]);

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            for (int i = 0; i < lstPrim.Count; i++)
            {
                if (lstPrim[i] >= iX) { iOut = lstPrim[i]; break; }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

        // 前準備 100000以下の素数取得+100003も
        private static List<int> GetPrim()
        {
            // 前準備 100000以下の素数取得
            int iMax = 1000000;   // 1000以下の素数が既知であるのが前提
            List<int> lstPrm = new List<int>() { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, };
            List<Boolean> lstMan = new List<Boolean>();
            for (int i = 0; i <= iMax; i++) { lstMan.Add(true); }
            lstMan[0] = false; lstMan[1] = false;
            for (int i = 0; i < lstPrm.Count; i++) { for (int j = 2; j <= iMax / lstPrm[i]; j++) { lstMan[lstPrm[i] * j] = false; } }
            List<int> lstNew = new List<int>();
            for (int i = 0; i < lstMan.Count; i++) { if (lstMan[i]) { lstNew.Add(i); } }
            lstNew.Add(100003);
            return lstNew;
        }

}


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

int main()
{
    int N;
    cin >> N;
    vector<int> P1, P2;
    while(N--) {
        int p;
        cin >> p;
        P1.push_back(p);
        P2.push_back(p);
    }

    sort(P2.begin(), P2.end());

    bool valid = true;
    int dct = 0;
    for (int i=0; i<P1.size(); i++) {
        if (P1[i] != P2[i]) {
            dct++;
            if (dct > 2) {
                valid = false;
            }
        }
    }

    if (valid) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x-a) > abs(x-b))cout << "B";
    else cout << "A";
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

constexpr long long MOD = 1000000007;

int main()
{
  int A, P;
  std::cin >> A >> P;
  P += 3 * A;
  std::cout << P / 2 << std::endl;
  return 0;
}


Measured memory_bytes: 256