akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int[] d = IntStream.range(0, sc.nextInt()).map(e -> sc.nextInt()).toArray();
        int ans = 0;
        for (int i = 0; i < d.length; i++) {
            for (int j = 0; j < d.length; j++) {
                if (i != j)
                    ans += d[i] * d[j];
            }
        }

        System.out.println(ans / 2);
        sc.close();
    }
}

Measured memory_bytes: 26708
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

//typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
//typedef vector<ll> vl;
//typedef vector<vl> vll;
typedef pair<int,int> pii;
//typedef pair<ll,ll> pll;

vi v(4);
string e="",enz="+-*";
int f;

int calc(int a,int b,char c){
	if(c=='+')return a+b;
	if(c=='-')return a-b;
	if(c=='*')return a*b;
	return -1;
}

bool judge1(string s){
	return calc(calc(calc(v[0],v[1],s[0]),v[2],s[1]),v[3],s[2])==10;
}

bool judge2(string s){
	return calc(calc(v[0],v[1],s[0]),calc(v[2],v[3],s[2]),s[1])==10;
}

void solve(string s){
	if(f!=0)return;
	if(s.size()==3){
		if(judge1(s)){
			f=1;
			e=s;
		}
		if(judge2(s)){
			f=2;
			e=s;
		}
		return;
	}
	rep(i,3){
		string s2=s;
		s2+=enz[i];
		solve(s2);
	}
}

int main(){
	while(1){
		cin>>v[0]>>v[1]>>v[2]>>v[3];
		if(v[0]==0&&v[1]==0&&v[2]==0&&v[3]==0)break;
		e="";
		f=0;
		sort(all(v));
		do{
			solve(e);
			if(f==1){
				cout<<"(("<<v[0]<<" "<<e[0]<<" "<<v[1]<<") "<<e[1]<<" "<<v[2]<<") "<<e[2]<<" "<<v[3]<<endl;
				break;
			}
			else if(f==2){
				cout<<"("<<v[0]<<" "<<e[0]<<" "<<v[1]<<") "<<e[1]<<" ("<<v[2]<<" "<<e[2]<<" "<<v[3]<<")"<<endl;
				break;
			}
			//cout<<v[0]<<v[1]<<v[2]<<v[3]<<endl;
		}while(next_permutation(all(v)));
		if(f==0)cout<<"0"<<endl;
	}
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <cmath>
#include <iomanip>
#include <stdexcept>
// #include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; i++)
#define rep1(i,h) for(int i = 0; i <= h; i++)
#define rep2(i,n,h) for(int i = n; i < h; i++)
#define rep3(l,n,h) for(int l = n; i <= h; i++)

using namespace std;


int main(void) {
    double n,t,a, ans =1e10 ,j;
    cin >> n >> t >> a;
    rep(i,n) {
        double h;
        cin >> h;
        double k = t - h * 0.006;
        double res = abs(a - k);
        if(ans > res) {
            ans = res;
            j = i + 1;
        }
}
  cout << j;
    return 0;
}






Measured memory_bytes: 256
#include <stdio.h>
 
int Calc_num(int a, int b, int ma) {
	if (a <= b) {
		return a;
	}
	else {
		return b;
	}
}
 
int main(void)
{
        int N = 0;  // 調査対象者
	int A = 0;  // 新聞X購読者数
	int B = 0;  // 新聞Y購読者数
	int max = 0;  // 両新聞の最大購読者数
	int min = 0;  // 両新聞の最小購読者数
 
        scanf("%d ", &N);
        scanf("%d ", &A);
        scanf("%d", &B);
    
        if (1 <= N && N <= 100) {
		if (0 < A && A <= N) {
			if (0 < B && B <= N) {
				if (A == N && B == N) {
					max = N;
					min = N;
				}
				else if(A + B <= N){
					min = 0;
					max = Calc_num(A, B, max);
				}
				else {
					min = A + B - N;
					max = Calc_num(A, B, max);
				}
			}
		}
	}
 
	//  結果の出力
	printf("%d %d\n", max, min);
 
	return 0;
}

Measured memory_bytes: 128
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
template <typename Monoid >
struct SegmentTree{
  using F = function< Monoid(Monoid,Monoid) >;

  int sz;
  vector<Monoid> seg;

  const F f;
  const Monoid M;

  SegmentTree(int n,const F f,const Monoid &M) : f(f),M(M){
    sz = 1;
    while(sz<n) sz<<=1;
    seg.assign(sz*2,M);
  }
  void set(int k,const Monoid &v){
    seg[k+sz] = v;
  }
  void build(){
    for(int k=sz-1;k>0;k--){
      seg[k] = f(seg[2*k],seg[2*k+1]);
    }
  }
  void update(int k,const Monoid &v){
    k += sz;
    seg[k] = v;
    while(k >>= 1){
      seg[k] = f(seg[2*k],seg[2*k+1]);
    }
  }
  Monoid que(int a,int b){
    Monoid L=M,R=M;
    for(a+=sz, b+=sz;a<b;a>>=1,b>>=1){
      if(a&1) L = f(L,seg[a++]);
      if(b&1) R = f(seg[--b],R);
    }
    return f(L,R);
  }
  Monoid operator[](const int &k) const{
    return seg[k+sz];
  }
};
signed main(){
  init_io();
  ll n,l=0,r=1100000000,h,cnt;
  cin >> n;
  ll m = ((n*(n+1))/2)/2;
  vector<ll> a(n),ca(n),s(n+1);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  ll base = n+1;
  while(r-l>1){
    ll sum = 0;
    cnt = 0;
    h = (r+l)/2;
    SegmentTree<ll> seg(2*n+10,[](ll a,ll b){return a+b;},0);
    vector<P> tmp(n);
    seg.update(sum+base,1);
    for(int i=0;i<n;i++){
      if(a[i]<=h) ca[i] = 1;
      else ca[i] = -1;
      sum += ca[i];
      cnt += seg.que(1,sum+base);
      seg.update(sum+base,seg[sum+base]+1);
    }
    if(cnt>m){
      r = h;
    }else{
      l = h;
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 10336
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
int main(void){
    int c=0;;
    int n;
    cin >>n;
    vector<int>a(n,0);
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    for(int j=0; j<n-2; j++){
        if(a[j]>a[j+1]&&a[j+1]>a[j+2]){
            c++;
        }else if(a[j]<a[j+1]&&a[j+1]<a[j+2]){
            c++;
        }
    }

    cout <<c <<endl;


    return 0;
}

Measured memory_bytes: 256
use List::Util 'min';

while(<>){
	chomp;
	($n, $x, $y) = split(/ /, $_);
}

%cnt = ();
for $i (1 .. $n - 1){
	$r = 0;
	for $m (1 .. $n - $i){
		$j = $i + $m;
		$cnt{min($m, abs($x - $i) + 1 + abs($j - $y), abs($y - $i) + 1 + abs($j - $x))}++;
	}
}

for $i (1 .. $n - 1){
	unless($cnt{$i}){
		print "0\n";
	}else{
		print "$cnt{$i}\n";
	}
}

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

using namespace std;

int n;
long long dp[102][100010];
long long v[111], w[111];

long long get(int curr, int wei) {
    if (wei < 0) {
        return 0;
    }
    if (curr == 0) {
        if (wei >= w[curr]) return v[curr];
        return 0;
    }

    if (dp[curr][wei] != -1)    return dp[curr][wei];

    long long ans = -1;
    if (wei - w[curr] >= 0)
        ans = v[curr] + get(curr-1, wei-w[curr]);
    ans = max(ans, get(curr-1, wei));

    // cout<<"set: "<<curr<<" "<<wei<<" : "<<ans;
    dp[curr][wei] = ans;
    return ans;
}

int main(void) {
    int W;
    cin>>n>>W;

    for(int i = 0; i < n; ++i) {
        cin>>w[i]>>v[i];
        for (int j = 0; j <= W; ++j) {
            dp[i][j] = -1;
        }
    }

    cout<<get(n-1, W);

    return 0;
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)N;i++)
int main()
{
  int a=0,b=0,x=1,N,count=0,checkA=0,checkB=0;
  cin>>N;
  vector<int> A(N,0),B(N,0),C(N,0);
  rep(i,N){cin>>A.at(i);}rep(i,N){cin>>B.at(i);}rep(i,N){C.at(i)=i+1;}
  rep(i,N)x=(x*(i+1))%(int)(1e9+7);
  while(count<x)
  {
    checkA=checkB=0;
    rep(i,N)
    {
      if(A.at(i)==C.at(i))checkA++;
      if(B.at(i)==C.at(i))checkB++;
    }
    if(checkA==N)a=count+1;
    if(checkB==N)b=count+1;
    if(a*b!=0)break;
    next_permutation(C.begin(),C.end());
    count++;
  }
  if(a>b)swap(a,b);
  cout<<b-a<<endl;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    int K;
    cin >> K;
    vector<int> H(N);

    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    int ans = 0;
    for (int i : H) {
        if (i >= K) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<climits>
#include<algorithm>

using namespace std;
int main(){
    int n,x;
    int min_num = 1000000,max_num = -1000000;
    long long sum = 0;
    scanf("%d",&n);
    for(int i = 0;i < n;i++){
        scanf("%d",&x);
        min_num = min(min_num,x);
        max_num = max(max_num,x);
        sum += x;
    }
    printf("%d %d %lld\n",min_num,max_num,sum);
    return 0;
}


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

// Backtracking the Dp table to find the longest common subsequence
string backTrack(int i, int j, string& a, string& b, vector<vector<int>>& dp){

    if(i < 1 or j < 1) return "";

    if(a[i - 1] == b[j - 1]) return backTrack(i - 1, j - 1, a, b, dp) + a[i - 1];

    if(dp[i - 1][j] == dp[i][j]) return backTrack(i - 1 ,j, a, b, dp);
    else return backTrack(i, j - 1, a, b, dp);
}

// Using Iterative Dynmaic programming to calculate Longest Common Subsequence
string lcs(string a, string b){
    int n = a.size(), m = b.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1));

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            if(a[i - 1] == b[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
            else dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
        }
    }
    return backTrack(n , m, a, b, dp);
}

void testcase(){
    string a, b;
    cin >> a >> b;
    cout << lcs(a, b);
}

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

#ifdef AKP
    freopen("in.txt", "r", stdin);
#endif

    int t = 1;
    //cin >> t;
    while(t--){
        testcase();
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 35968
#include<bits/stdc++.h>
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ppb pop_back
using namespace std;
typedef long long int ll;
int  main(){
	ll n,m;
	cin>>n>>m;
	ll t=min(n,m);
	for(int i=0;i<max(m,n);i++){
		cout<<t;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;


const int mod = 1000000007;



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

    ll n;
    cin>>n;
    ll a[n],b[n];
    ll beki[n+1]={};
    beki[0] = 1;
    for(int i=0;i<n;i++){
        beki[i+1] = beki[i] * 2;
        beki[i+1] %= mod;
    }
    ll ans = 1;
    ll cnt = 0;
    map<array<ll,2>,ll> mp;
    ll l=0,r=0;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        if(a[i]==0 && b[i]==0){
            cnt++;
            continue;
        }
        if(a[i]==0){
            l++;
            continue;
        }
        if(b[i]==0){
            r++;
            continue;
        }
        ll g = max(1LL,gcd(abs(a[i]),abs(b[i])));
        a[i] /= g;
        b[i] /= g;
        if(a[i]<0 && b[i]<0){
            a[i] = -a[i];
            b[i] = -b[i];
        }
        if(b[i] < 0 && a[i] > 0){
            a[i] = -a[i];
            b[i] = -b[i];
        }
        mp[{a[i],b[i]}]++;
    }
    map<array<ll,2>,bool> used;

    for(auto i:mp){
        if(used[i.first])continue;
        ll ret = beki[i.second];
        array<ll,2> now = i.first;
        used[now] = 1;
        if(mp.count({-now[1],now[0]}) || mp.count({now[1],-now[0]})){
            used[{-now[1],now[0]}] = 1;
            used[{now[1],-now[0]}] = 1;
            ll tmp = 0;
            if(mp.count({-now[1],now[0]}))tmp=mp[{-now[1],now[0]}];
            if(mp.count({now[1],-now[0]}))tmp+=mp[{now[1],-now[0]}];
            ret += beki[tmp];
            ret += mod-1;
            ret %= mod;
        }
        ans *= ret;
        ans %= mod;
    }

    ll ret = beki[l] + beki[r];
    ret %= mod;
    ret += mod-1;
    ret %= mod;
    ans *= ret;
    ans %= mod;


    ans += cnt;
    ans %= mod;
    ans += mod-1;
    ans %= mod;
    cout << ans << endl;
    // 0 に注意


}

Measured memory_bytes: 33192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, t;
  cin >> n >> t;
  vector<P> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(all(p));
  vl dp(6010, 0);
  rep(i, n) for(ll j = t - 1; j >= 0; j--) {
    ll a = p[i].first;
    ll b = p[i].second;
    dp[j + a] = max(dp[j + a], dp[j] + b);
  }
  ll ans = 0;
  rep(i, 6010) ans = max(ans, dp[i]);
  cout << ans << endl;
}

Measured memory_bytes: 3728
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

#define int long long

//#define ENABLE_TRACE
#ifdef ENABLE_TRACE
#define TRACE cout << __func__ << "()" << endl;
#define TRACE1(a) cout << __func__ << "(" << a << ")" << endl;
#define TRACE2(a, b) cout << __func__ << "(" << a << ", " << b << ")" << endl;
#else
#define TRACE
#define TRACE1(a)
#define TRACE2(a, b)
#endif  // #ifdef ENABLE_TRACE

using namespace std;

// Greatest Common Divisor
int Gcd(int a, int b) {
  TRACE2(a, b);
  if (a % b == 0)
    return b;
  return Gcd(b, a % b);
}

void Main() {
  int x;
  cin >> x;

  int yokin = 100;
  int year = 0;
  while (yokin < x) {
    year++;
    yokin += yokin * 0.01;
  }
  cout << year << endl;
}

int32_t main() {
  Main();
  return 0;
}

Measured memory_bytes: 3608
#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 a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = max({a*c, a*d, b*c, b*d});
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
x, n = map(int, input().split())
if n ==0:
  print(x)
  exit()
else:
  p = list(map(int, input().split()))
a = 0
b = 0
while True:
  if (x - a) not in p:
    print(x-a)
    exit()
  a += 1
  if (x + b) not in p:
    print(x+b)
    exit()
  b += 1

Measured memory_bytes: 9084
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  bool is_prime[52000];
  is_prime[0]=false;is_prime[1]=false;
  for(int i=2;i<52000;i++)is_prime[i]=true;
  for(int i=2;i<=sqrt(51999);i++){
    if(is_prime[i]){
      for(int j=2;i*j<=51999;j++)is_prime[i*j]=false;
    }
  }

  int n;
  while(cin>>n){
    int index=n-1;
    while(!is_prime[index]){
      index--;
    }
    cout<<index<<' ';

    index=n+1;
    while(!is_prime[index]){
      index++;
    }
    cout<<index<<endl;
  }
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define int long long
constexpr int MOD = 1e9 + 7;
using namespace std;

constexpr static int MAXN = 2002;
#define co(ans) cout<<ans<<endl
#define MAX 5100000

signed main(){
  int a;
  cin>>a;
  cout << a + a*a + a*a*a;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main()
{
    int a , b , time = 0 , ans = 0;
    double t;
    cin >> a >> b >> t;
    while (time <= t + 0.5){
        if (time + a > t + 0.5){
            break;
        }
        ans += b;
        time += a;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3664
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b, ma;
	cin >> a >> b;
	ma = max(a + b, a - b);
	ma = max(ma, a * b);
	cout << ma << endl;
} 

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

int main() {
	int n,m;
	cin >> n;
	m = n % 10;
	if(m==2||m==4||m==5||m==7||m==9){
		cout << "hon" << endl;
	}
	else if(m==0||m==1||m==6||m==8){
		cout << "pon" << endl;
	}
	else{
		cout << "bon" << endl;
	}

}



Measured memory_bytes: 3624
n,m = map(int,input().split())
a = []
lmax = 0
rmin = 10**6
for i in range(m):
    a.append(list(map(int,input().split())))
    if a[i][0] > lmax:
        lmax = a[i][0]
    if a[i][1] < rmin:
        rmin = a[i][1]
if rmin-lmax < 0 :
    print(0)
else :   
    print(1+rmin-lmax)


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

void Main()
{
    int k, a, b;
    cin >> k >> a >> b;
    int flag = 0;
    for (int i = a; i <= b; i++)
    {
        if (i % k == 0)
        {
            flag = 1;
        }
    }

    if (flag == 0)
    {
        cout << "NG" << endl;
    }
    else
    {
        cout << "OK" << endl;
    }
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vi=vector<int>;  using vs=vector<string>; using gi=greater<int>;
#define soao(c) sort((c).begin(),(c).end()) //昇順
#define sodo(c) sort((c).begin(),(c).end(),gi()) //降順
#define rev(c) reverse((c).begin(), (c).end())

int main() {
  int num; cin>>num;
  int syain;
  vi boss(num,0);
  rep(i,num-1){
    cin>>syain;
    boss.at(syain-1)++;
  }
  rep(i,num) cout<<boss.at(i)<<endl;
}


Measured memory_bytes: 4048
# -*- coding: utf-8 -*-
# input
s = input()
s1 = s0 = 0
for j in range(len(s)):
    if j % 2 == 0 and int(s[j]) == 0:
        pass
    elif j % 2 == 1 and int(s[j]) == 1:
        pass
    else:
        s0 += 1
    if j % 2 == 0 and int(s[j]) == 1:
        pass
    elif j % 2 == 1 and int(s[j]) == 0:
        pass
    else:
        s1 += 1
print(min(s1, s0))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string S;
cin >> S;
if (S == "Sunny") cout << "Cloudy" << endl;
else if (S == "Cloudy") cout << "Rainy" << endl;
else cout << "Sunny" << endl;



return 0;
}

Measured memory_bytes: 256
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int n,k; cin >> n >> k;
    vi p(n); rep(i,n) cin >> p[i];
    vi c(n); rep(i,n) cin >> c[i];
    vv<int> score;
    int idx = 0;
    vector<bool> used(n);
    vi now;
    rep(i,n){
        if(!used[i]) idx = i;
        else continue;
        idx = p[idx]-1;
        while(!used[idx]){
            now.emplace_back(c[idx]);
            used[idx] = true;
            idx = p[idx]-1;
        }
        score.emplace_back(now);
        now.clear();
    }
    ll res = -LINF;
    rep(ii,score.size()){
        int k2 = k;
        vi &s = score[ii];
        int sz = s.size();
        ll sum = 0;
        ll loop = 0;
        rep(i,sz) sum += s[i];
        if(sum>=0){
            loop = k2/sz;
            k2 %= sz;
        }
        vll ac(sz*2+1);
        rep(i,sz){
            ac[i+1] = ac[i] + s[i];
        }
        rep(i,sz){
            ac[i+sz+1] = ac[i+sz] + s[i];
        }
        ll ans2 = -LINF;
        rep(i,sz*2+1)rep(j,i+1){
            if(i-j>k2 || i-j>=sz) continue;
            if(loop==0 && i==j) continue;
            chmax(ans2, ac[i]-ac[j]);
        }
        chmax(res, sum*loop+ans2);
        if(loop>0){
            ll ans3 = LINF;
            rep(i,sz*2+1)rep(j,i+1){
                if(i-j>=sz) continue;
                chmin(ans3, ac[i]-ac[j]);
            }
            chmax(res, sum*loop-ans3);          
        }
    }

    cout << res << '\n';
    

}


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


#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define print(x) cout << x << endl;
typedef long long ll;

constexpr ll INF = 1'010'000'000'000'000'017LL;\
constexpr ll MOD = 1'000'000'007LL;\
constexpr double EPS = 1e-12;\
constexpr double PI = 3.14159265358979323846;

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = 0;
    ans += A * (N / (A+B));
    if (N % (A+B) > A) {
        ans += A;
    } else {
        ans += N % (A+B);
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
int main(void){
    ll N,W;cin>>N>>W;
    ll v[N],w[N];REP(i,N)cin>>v[i]>>w[i];
    ll dp[W+1]={};
    REPS(j,W){
        REP(i,N){
            if(w[i]<=j){
                dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
            }
            dp[j]=max(dp[j],dp[j-1]);
        }
    }
    cout<<dp[W]<<"\n";
}


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



int main() {

int n,c=0,x;
cin >> n;

for (int i = 1 ; i <= n ; i++){

      cin >>x ;

       if ( x%2 != 0 && i % 2 != 0){
        c++;
       }
}

cout << c << endl ;



	return 0;

}


Measured memory_bytes: 3564
#!/usr/bin/env python
# -*- coding: utf-8 -*-

while True:
    N,M,P = map(int,input().split(" "))
    if N == 0 and M == 0 and P == 0:
        break
    count = 0
    for i in range(N):
        x = int(input())
        count += x
        if i + 1 == M:
            hitman = x
    if hitman == 0:
        print(0)
    else:
        print(int((count)*((100-P))/hitman))

Measured memory_bytes: 6724
LOWER, UPPER = range(2)
MAX_DIGIT = 33
n = 0
bounds = [0] * MAX_DIGIT
for digit in range(MAX_DIGIT):
    n = (n << 1) | (digit & 1)
    bounds[digit] = [-(n >> (digit & 1)), n >> (not (digit & 1))]

N = int(input())

answer = 0
n = (1 << digit) * (1 if MAX_DIGIT & 1 else -1)

while digit:
    answer <<= 1
    n = (-1) * n >> 1
    if bounds[digit][LOWER] <= N < bounds[digit - 1][LOWER] or \
        bounds[digit - 1][UPPER] < N <= bounds[digit][UPPER]:
        answer |= 1
        N -= n
    digit -= 1

print(format(answer, "b"))

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int a,n,i,j;
    scanf("%d%d",&a,&n);
    if(a>=13)
    {
        printf("%d\n",n);
    }
    else if(a>=6 && a<=12)
    {
        printf("%d\n",n/2);
    }
    else
        printf("0\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

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

        if (N * A < B) {
            System.out.println(N * A);
        } else {
            System.out.println(B);
        }
    }
}

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

int num[4];
int op[3];
char s_op[3] = {'-', '+'};
bool eval() {
    int res = num[0];
    for (int i = 0; i < 3; i++) {
        if (op[i] == 0) {
            res -= num[i+1];
        } else {
            res += num[i+1];
        }
    }
    if (res == 7) {
        cout << num[0];
        for (int i = 0; i < 3; i++) {
            cout << s_op[op[i]] << num[i+1];
        }
        cout << "=" << "7" << "\n";
        return true;
    }
    return false;
}
bool break_flag = false;
void full_search(int i) {
    if (break_flag == true) return;
    if (i == 4) {
        if(eval()) break_flag = true;
    } else {
        op[i] = 0;
        full_search(i+1);
        op[i] = 1;
        full_search(i+1);
    }
}

int main() {
    int n;
    cin >> n;
    for (int i = 3; i >=0; i--) {
        num[i] = n%10;
        n /= 10;
    }
    
    full_search(0);

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n;
  cin >> n;
  vector<pii> red(n);
  rep(i,n) cin >> red[i].first >> red[i].second;
  set<pii> blue;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    blue.insert(pii(a,b));
  }
  sort(all(red));
  reverse(all(red));
  int ans=0;
  rep(i,n){
    int height=inf;
    pii tagc=pii(-1,-1);
    for(auto c:blue){
      if(red[i].first<c.first&&red[i].second<c.second){
        if(c.second-red[i].second<height){
          height=c.second-red[i].second;
          tagc=c;
        }
      }
    }
    if(tagc!=pii(-1,-1)){
      blue.erase(tagc);
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <complex>
#include <cmath>
#include <algorithm>

using namespace std;

int n;
int x[500], y[500], z[500];

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> z[i];
    }
    for (int X = 0; X <= 100; X++)
    {
        for (int Y = 0; Y <= 100; Y++)
        {
            vector<pair<int, int> > he;
            for (int i = 0; i < n; i++)
            {
                int a = abs(X - x[i]) + abs(Y - y[i]);
                if (z[i] > 0)
                {
                    he.push_back({z[i] + a, 1});
                }
                else
                {
                    he.push_back({a, 0});
                }
            }
            sort(he.begin(), he.end());
            int H = 1;
            for (int i = 0; i < n; i++)
            {
                if (he[i].second == 1)
                {
                    H = he[i].first;
                    break;
                }
            }
            //cout << X << " " << Y << " " << H << endl;
            int t = 1;
            for (int i = 0; i < n; i++)
            {
                int a = abs(X - x[i]) + abs(Y - y[i]);
                a = max(H - a, 0);
                if (a != z[i])
                {
                    t = 0;
                }
            }
            if (t)
            {
                cout << X << " " << Y << " " << H << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 384
//h17-4
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)

int main(){
    int N;
    cin >> N;
    int t[100000];
    int m = 0;
    for(int i=0; i<N; i++){
        cin >> t[i];
        m = max(m, t[i]);
    }

    set<int> yakusu;
    for(int i=1; i<=m; i++){
        if(m % i == 0) yakusu.insert(i);
    }
    LL ans = 0;
    for(int i=0; i<N; i++){
        ans += *(yakusu.lower_bound(t[i])) - t[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200001;
ll dp[N];
ll getMid(ll s, ll e)  { 
    return s + (e - s) / 2; 
} 
ll MaxUtil(ll* st,ll ss,ll se,ll l,ll r,ll node) { 
    if (l <= ss && r >= se) 
        return st[node]; 
    if (se < l || ss > r) 
        return -1; 
    ll mid = getMid(ss,se); 
    return max(MaxUtil(st,ss,mid,l,r,2*node+1), MaxUtil(st,mid+1,se,l,r,2*node+2)); 
} 
void updateValue(ll arr[],ll* st,ll ss,ll se,ll index,ll value,ll node) { 
    if (index < ss || index > se)  { 
        cout<<"Invalid Input"<<endl; 
        return; 
    } 
    if(ss == se)  {    
        arr[index] = value; 
        st[node] = value; 
    } 
    else { 
        ll mid = getMid(ss, se);   
        if (index >= ss && index <= mid) 
            updateValue(arr,st,ss,mid,index,value,2*node+1); 
        else
            updateValue(arr,st,mid+1,se,index,value,2*node+2); 
        st[node] = max(st[2*node+1],st[2*node+2]); 
    } 
    return; 
} 
ll getMax(ll* st,ll n,ll l,ll r) { 
    if (l < 0 || r > n - 1 || l > r) { 
        printf("Invalid Input"); 
        return -1; 
    } 
    return MaxUtil(st,0,n-1,l,r,0); 
} 
ll constructSTUtil(ll arr[],ll ss,ll se,ll* st,ll si) { 
    if (ss == se)  { 
        st[si] = arr[ss]; 
        return arr[ss]; 
    } 
    ll mid = getMid(ss, se); 
    st[si] = max(constructSTUtil(arr,ss,mid,st,si*2+1), 
                 constructSTUtil(arr,mid+1,se,st,si*2+2)); 
    return st[si]; 
} 
ll* constructST(ll arr[], ll n) { 
    ll x = (int)(ceil(log2(n))); 
    ll max_size = 2*(int)pow(2,x)-1; 
    ll* st = new ll[max_size]; 
    constructSTUtil(arr,0,n-1,st,0); 
    return st; 
} 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // n = 10;
    // ll a[10] = {1,2,3,4,5,6,7,8,9,10};
    // ll st = constructST(a,n);
    int n; cin>>n; ll h[n+1],c[n+1];
    for(int i = 0; i < n; ++i) cin>>h[i];
    for(int i = 0; i < n; ++i) cin>>c[i];
    ll* tree = constructST(dp,n);
    for(int i = 0; i < n; ++i) {
        if(h[i] == 1) 
            updateValue(dp,tree,0,n-1,0,c[i],0);
        else {
            ll z = getMax(tree,n,0,h[i]-2);
            updateValue(dp,tree,0,n-1,h[i]-1,z+c[i],0);
        }
    }
    // for(int i = 0; i < n; ++i) cout<<dp[i]<<" ";
    // cout<<"\n";
    cout<<*max_element(dp,dp+n)<<"\n";
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
 
#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) {cout << a; exit(0);}
 
using namespace std;                                                                                  
 
mt19937 mrand(random_device{}()); 
const ll mod = 1e9 + 7;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
 
typedef pair < int , int > pii ;                                            
typedef pair < long long  , long long > pll ;
 
const int N = 3e5 + 123;
 
int n, m, k;
vector < pii > gr[N];
int a[N];
int dp1[N] , cnt1[N], dp2[N], cnt2[N] , w[N] , v[N] , u[N];
 
main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int s , t;
	cin >> n >> m >> s >> t;
 
	rep(i , 1 , n)
		dp1[i] = dp2[i] = 1e17;
	dp1[s] = dp2[t] = 0;
	cnt1[s] = cnt2[t] = 1;
	
	for(int i = 1; i <= m; i++){
		cin >> u[i] >> v[i] >> w[i];
		gr[u[i]].pb({v[i],w[i]});
		gr[v[i]].pb({u[i],w[i]});
	}
	set < pii > st;
	st.insert({0 , s});
	
	while(sz(st) != 0){
		int u = (*st.begin()).se;
		st.erase(st.begin());
		for(auto to : gr[u]){
			if(dp1[to.fi] == dp1[u] + to.se)
				cnt1[to.fi] += cnt1[u], cnt1[to.fi] %= mod;
			else if(dp1[to.fi] > dp1[u] + to.se){
				st.erase({dp1[to.fi] , to.fi});
				dp1[to.fi] = dp1[u] + to.se;
				cnt1[to.fi] = cnt1[u];
                st.insert({dp1[to.fi],to.fi});
			}
		}
	}    
 
	st.insert({0 , t});
	while(sz(st) != 0){
		int u = (*st.begin()).se;
		st.erase(st.begin());
		for(auto to : gr[u]){
			if(dp2[to.fi] == dp2[u] + to.se)
				cnt2[to.fi] += cnt2[u] , cnt2[to.fi] %= mod;
			else if(dp2[to.fi] > dp2[u] + to.se){
				st.erase({dp2[to.fi] , to.fi});
				dp2[to.fi] = dp2[u] + to.se;
				cnt2[to.fi] = cnt2[u];
                st.insert({dp2[to.fi],to.fi});
			}
		}
	}	
	int tot = cnt1[t] * cnt1[t]%mod;
	for(int i = 1; i <= m; i++){
		if(dp1[u[i]] + dp2[v[i]] > dp2[u[i]] + dp1[v[i]])
			swap(u[i],v[i]);
		if(dp1[u[i]] + dp2[v[i]] + w[i] == dp1[t]){
			int l = max(dp1[u[i]],dp2[v[i]]) , r = min(dp1[u[i]],dp2[v[i]])+w[i];
			if(l < r)
				tot -= cnt1[u[i]] * cnt2[v[i]] % mod * cnt1[u[i]] % mod * cnt2[v[i]] % mod , tot += mod , tot %= mod;//input//
		}
	}
 
	for(int i = 1; i <= n; i++)
		if(dp1[i] + dp2[i] == dp1[t] and dp1[i] == dp2[i])  //this 
			tot -= cnt1[i] * cnt2[i] % mod * cnt1[i] %mod * cnt2[i] % mod , tot += mod , tot %= mod;
 
 
	ret(tot);
        
}

Measured memory_bytes: 39024
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

template<typename t1, class t2>
void input(t1 count,t2* array) {
	for(t1 i = 0;i < count;i++) {
		cin >> array[i];
	}
}

template<typename t1, class t2>
void output(t1 count,t2* array) {
	for(t1 i = 0;i < count;i++) {
		cout << array[i];
		if(i != count - 1) cout << " ";
	}
	cout << endl;
}

template<class T>
class my_stack{
private:
	size_t cAlloc = 0;
	int sp = 0;
	T* arr;
public:
	my_stack(size_t size) {
		cAlloc = size;
		arr = new T[cAlloc];
	}
	T pop() {
		if(sp == 0) return T();
		sp--;
		return arr[sp];
	}
	void push(T e) {
		if(sp == cAlloc) return;
		arr[sp] = e;
		sp++;
		return ;
	}
	void dump() {
		for(int i = 0;i < sp;i++) {
			cout << arr[i] << " ";
		}
		cout << endl;
	}
};

int main(int argc,char** argv) {
	vector<string> t;
	string s;
	getline(cin,s);
	int d = 0,r = 0;
	while(d < s.size()) {
		while(r != s.size() && s[r] != ' ') r++;
		t.push_back(s.substr(d,r - d));
		r++;
		d = r;
	}
	my_stack<int> acm(1000);
	for(auto e:t) {
		switch(e[0]) {
		case '+':
			acm.push(acm.pop()+acm.pop());
			break;
		case '-':
			acm.push((acm.pop()-acm.pop()));
			acm.push(-acm.pop());
			break;
		case '*':
			acm.push(acm.pop() * acm.pop());
			break;
		default:
			acm.push(atoi(e.c_str()));
			break;
		}
	}
	cout << acm.pop() << endl;
}



Measured memory_bytes: 3216
#include <iostream>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
constexpr ll mod = 1000000007;

int main() {
    int n;
    vector<string> s(2);
    cin >> n >> s[0] >> s[1];
    ll c = 1;
    string e;
    for (int i = 0; i < n; i++) {
        if (s[0][i] == s[1][i]) e += "v";
        else {
            i++;
            e += "h";
        }
    }
    if (e[0] == 'h') c = 6;
    else c = 3;
    for (int i = 1; i < e.length(); i++) {
        if (e[i] == 'h') {
            if (e[i - 1] == 'h') c *= 3;
            else c *= 2;
        } else {
            if (e[i - 1] == 'h') c *= 1;
            else c *= 2;
        }
        c = c % mod;
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{
    char x[1001];
    int n;
    do
    {
        scanf("%s", x);
        n = 0;
        for (int i = 0; i < strlen(x); i++)
        {
            n = n + x[i] - '0';
        }
        if (n != 0)
        {

            printf("%d\n", n);
        }

    } while (n != 0);

    return 0;
}


Measured memory_bytes: 2108
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;

int main(){
    int X,Y,Z;
    cin >> X >> Y >> Z;
    cout << (X-Z)/(Y+Z) << endl;
    return 0;
}


Measured memory_bytes: 256
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
for a in range(N-2):
    for b in range(a+1,N-1):
        c = bisect.bisect_left(L,L[a]+L[b])
        ans += c-b-1
            
print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double p = 0;    //入力された値Nまでの奇数の個数

    int num = sc.nextInt();
    for(int i = 0; i <= num; i++){
      if((i % 2) == 1){
        p++;
      }
    }

    System.out.printf("%.10f \n" , p/num);
  }
}

Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;


int main(){
    string str;
    getline(cin,str);
    int i=0;
    
    while(str[i]){
        char c=str[i];
        if(isupper(c)){
            printf("%c",tolower(c));
            
        }else if(islower(c)){
            printf("%c",toupper(c));
        }else{
            printf("%c",c);
        }
        ++i;
    }
    cout<<endl;
}



Measured memory_bytes: 3196
def get_num(n, x):
    ans = 0
    for n3 in range(min(n, x), (x + 2) / 3, -1):
        for n2 in range(n3 - 1, (x - n3 + 1) / 2 - 1, -1):
            for n1 in range(n2 - 1, 0, -1):
                s = n1 + n2 + n3
                if s == x:
                    ans += 1
                    break
    return ans


while True:
    [n, x] = [int(m) for m in raw_input().split()]
    if [n, x] == [0, 0]:
        break
    if x == 0:
        print(0)
    else:
        print(get_num(n, x))

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

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

Measured memory_bytes: 256
a,b = input().split()
if a == 'H' and b == 'H':
    print('H') 
elif a == 'D' and b == 'H':
    print('D') 
elif a == 'D' and b == 'D':
    print('H') 
elif a == 'H' and b == 'D':
    print('D') 
    

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

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

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

    ll sum = 0;
    int cnt = 0;
    while (sum < x) {
        cnt++;
        sum += cnt;
    }

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



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 1000000007;

//cout << fixed << setprecision(10);

int main() {
    ll N;
    cin >> N;
    ll ans=0;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
    for(int i=0;i<N;i++){
        ans+=A[i]/2;
        A[i]%=2;
        if(i+1<N){
            ll d = min(A[i],A[i+1]);
            A[i]-=d;
            A[i+1]-=d;
            ans+=d;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
// Devarshi

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn=1000001;

int main(){

sync


string s;
cin>>s;
int n=s[0]-'0';
bool flag=true;
fore(i,1,2){
if(s[i]-'0'>n){
    flag=false;
    break;
}
}
if(flag){
    forn(i,3){
        cout<<n;
    }
}
else{
    forn(i,3){
        cout<<n+1;
    }
}
return 0;
}


Measured memory_bytes: 256
n = int(input())
d = sorted(list(map(int, input().split())))
dl = len(d)

if not dl%2 == 0:
    print(0)
    exit()
else:
    dl_mid_1 = dl//2
    dl_mid_2 = dl_mid_1 + 1
    k_min = d[dl_mid_1 - 1]
    k_max = d[dl_mid_2 - 1]
    print(k_max - k_min)

Measured memory_bytes: 20764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;


int main(void){
    int A,B,C;

    cin>>A>>B>>C;

    int ans;

    ans = (int)B/A;

    if(ans>C){
        cout<<C<<endl;
    }else{
        cout<<ans<<endl;
    }

    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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 pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 998244353;
const ld PI = acosl(-1);

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

    int N, S;
    cin >> N >> S;
    vector<vector<ll>> dp(N + 1, vector<ll>(S + 1));
    dp[0][0] = 1;
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        for (int j = 0; j <= S; ++j) {
            dp[i + 1][j] += dp[i][j] * 2;
            if (j >= A)
                dp[i + 1][j] += dp[i][j - A];
            dp[i + 1][j] %= MOD;
        }
    }

    cout << dp[N][S] << endl;

    return 0;
}


Measured memory_bytes: 73696
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m; cin>>n>>m;
  bool AC[n];
  int WA[n];
  
  int WAnum = 0;
  int ACnum = 0;
  for(int i = 1; i <= n; i++) {
        WA[i] = 0;
        AC[i] = false;
  }
  
  while(m--){
    int p; cin >> p;
    string s; cin >> s;
    if(AC[p]) continue;
    if(s=="AC") {
      AC[p]=true;
      ACnum++;
      WAnum+=WA[p];
    } else if (s=="WA"){
      WA[p]++;
    }
  }
  cout << ACnum << " " << WAnum << endl;
}

Measured memory_bytes: 768
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& a) {
  os << "{";
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? "," : "") << a[i];
  return os << "}";
}

[[maybe_unused]] constexpr ll MOD = 1000000007;
[[maybe_unused]] constexpr int INF = 0x3f3f3f3f;
[[maybe_unused]] constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, 0, n) cin >> a[i] >> b[i];

  bool ok = false;
  rep(i, 0, n - 2) {
    if (a[i] == b[i] && a[i + 1] == b[i + 1] && a[i + 2] == b[i + 2]) ok = true;
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3112
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
#define INFTY 1000000000000000000

int main(){
    LL n;
    LL w;
    cin >> n >> w;
    LL max_val=0;
    LL ans=0;
    vector<pair<LL, LL>> wv(n+1);
    for(LL i=1; i<=n; i++){
        cin >> wv[i].first >> wv[i].second;
        max_val+=wv[i].second;
    }
    vector<vector<LL>> dp(n+1, vector<LL>(max_val+1, INFTY));
    for(LL i=0; i<=n; i++){
        dp[i][0]=0;
    }
    for(LL i=1; i<=n; i++){
        for(LL j=0; j<=max_val; j++){
            dp[i][j]=dp[i-1][j];
            if(wv[i].second>j){
                continue;
            }
            dp[i][j]=min(dp[i][j], dp[i-1][j-wv[i].second]+wv[i].first);
        }
    }

    for(LL i=0; i<=max_val; i++){
        if(dp[n][i]<=w){
            ans=max(ans, i);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 83160
n = int(input())
ans = [0 for _ in range(10001)]

for x in range(1,100+1):
    for y in range(1,100+1):
        for z in range(1,100+1):
            tmp=x**2+y**2+z**2+x*y+y*z+z*x
            if tmp<=10000:
                ans[tmp]+=1

for i in range(n):
    print(ans[i+1])

Measured memory_bytes: 9348
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** +の符号 */
	private static final char PLUS = '+';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] s = scanner.next().toCharArray();
			int plus = (int) IntStream.range(0, s.length).filter(i -> s[i] == PLUS).count();
			System.out.println(plus - (s.length - plus));
		}
	}
}


Measured memory_bytes: 35932