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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, int> PLDI;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
const int INF = (1e9);
const LL MOD = 1e9+7;
const double PI=atan2(0,-1);

const int N=100001;
vector<int> parent(N,-1);//N is size
int Find(int p)
{
	return parent[p] < 0 ? p : parent[p] = Find(parent[p]);
}
void Merge(int p,int q)
{
	p=Find(p);q=Find(q);
	if(p==q) return;
	if(parent[p] < parent[q])
	{
		parent[p] += parent[q];
		parent[q]=p;
	}
	else
	{
		parent[q] += parent[p];
		parent[p]=q;
	}
}
bool Belong(int p, int q)
{
	return Find(p) == Find(q);
}
int GetSize(int p)
{
	return -parent[Find(p)];
}


int main()
{
    bool llist[100001];
    CLR(llist);
    
    int n,m;
    cin>>n>>m;
    //vector<vector<int> > l;
    REP(i,n)
    {
        int k,ll0;
        cin>>k;
        //vector<int> tmp;
        REP(j,k)
        {
            int ll;
            cin>>ll;
            //tmp.push_back(ll);
            
            llist[ll]=1;
            if(j>0)
            Merge(ll0, ll);
            else
            ll0=ll;
        }
        //l.push_back(tmp);
    }
    
    FOR(i,1,m+1)
    {
        if(!llist[i])continue;
        Merge(0,i);
        break;
    }
    
    bool flag=true;
    FOR(i,1,m+1)
    {
        if(!llist[i]) continue;
        if(!Belong(0,i))
        {
            flag=false;
            break;
        }
    }
    if(flag)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}

Measured memory_bytes: 896
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
	  #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
	   ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
		   # #  # # #                   # #      ###### #    # #    # #      #####
	  #    # #   #  #              #    # #      #    # #    # #    # #      #   #
	   ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<string> VS;
typedef vector<pair<LL, LL> > VP;
 
 
#define For(in) for (LL i = 0; i < (n); i++)
#define FOR(in) for(LL i=1; i <= (n); i++)
#define pb push_back
#define sr(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define exit(); return 0;
#define no "NO"
#define yes "YES"
#define con continue;
 
 
LL concate(LL a, LL b)
{
	ostringstream os;
	os <<a <<b;
	istringstream is(os.str());
	LL c;
	is>> c;
	return c;
}
 
 
LL check(char c)
{
	return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';
}
LL mod = 1e9+7;
 
 
int main()
{
	//LL q,t;
	//cin>>t;
	//while(t--)
	//{
	   LL a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,r=0,u=0,w=0,x=0,y=0,z=0;
		LL aa[1000];
		LL flag=0, flag1=0, co=0, co1=0, co2=0, co3=0, x1=0, x2=0, y1=0, y2=0, z1=0, z2=0;
		LL ma=0, mi=100000000;
		LL mid=0, temp=0, stop=0, start=0;
		double pi= 3.141592653589793;
		double d1=0.0, d2, d3, d4;
		VLL v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
		VS vs, vs1, vs2, vs3, vs4;
		VP vp, vp1,vp2;
		char ch, ch1, ch2[1001];
		string str, str1, str2, str3, str4, str5;
		pair<LL, LL> pa;
		list<LL> li, li1;
		map<LL, LL> mp, mp1;
		set<LL> st;
		map<LL ,LL> :: iterator imll;
		VLL :: iterator ivll;
		set<LL> :: iterator isll;
		VP :: iterator ivp;
 
		cin>>a>>b>>c;
		a *= 100;
		b *= 10;
		a += b;
		a+=c;
		if(a%4==0)cout<<yes<<endl;
		else cout<<no<<endl;
		
		
	exit()
 
 
}


Measured memory_bytes: 3628
#include<iostream>

using namespace std;

int main(){
    int N;

    cin >> N;

    if((N/10)%111==0){
        cout << "Yes";
        return 0;
    }
    if((N%1000)%111==0){
        cout << "Yes";
    }else{
        cout << "No";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

bool a[10];

    int main(){

    int N;
    int i=0;
    
    while(cin>>N)
    {
        
        i = 0;
        for(int j=0;j<10;j++)
        {
            a[j] = 0;
        }
        
        for(int k=9;k>-1;k--){
            
            if(i+(pow(2,k)) <= N){
                i += pow(2,k);
                a[k] = 1;
            }
        }
        
        bool last = false;
        for(int k=0;k<10;k++){
            
            if(a[k] ==1)
            {
                if(last){
                    cout<<" ";
                }
                last = true;
                cout<<pow(2,k);    
            }        
        }
 
        cout<<endl;
    }
}

Measured memory_bytes: 3372
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	cout<<((n)+(n*n)+(n*n*n))<<endl;
	return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n,m;
  while(cin >> n >> m, n+m) {
    vector<int> a(n);
    REP(i,n) {
      cin >> a[i];
    }
    sort(ALL(a), greater<int>());
    int res = 0;
    int i;
    for (i=0; i+m<=n; i+=m) {
      REP(j,m-1) {
        res += a[i+j];
        //    cout << a[i+j] << "" ; 
      }
      //cout << endl;
    }
    //  cout << i << endl;
    if (i < n) {
      REP(j, n-i) {
        res += a[i+j];
        //  cout << a[i+j] << endl;
      }
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		int ans = Integer.MAX_VALUE;
		for(long i = 1; i * i <= N; i++) {
			if(N % i == 0) {
				ans = Math.min(ans, Math.max(Long.toString(i).length(), Long.toString(N / i).length()));
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, q,s;
    string str;
    int64_t count = 0;
    cin >> n >> q;
    queue<int> que;
    queue<string> vec;
    for (int i=0; i<n; i++){
        cin >> str >> s;
        vec.push(str);
        que.push(s);
    }
    while(!que.empty()){
        if (que.front() - q <= 0){
            count += que.front();
            cout << vec.front() << " " << count << endl;
            que.pop();
            vec.pop();
        }else{
            count += q;
            que.push(que.front() - q);
            vec.push(vec.front());
            que.pop();
            vec.pop();
        }
    }
    return 0;
}


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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n,m,ans=0,k=-1;
  bool ok = false;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  vector<ll> b(m),c(m);
  vector<pair<ll,ll>> p(m);
  rep(i,m){
    cin >> b[i] >> c[i];
    p[i] = make_pair(c[i],b[i]);
  }
  sort(all(p),greater<pair<ll,ll>>());
  rep(i,m){
    rep(j,p[i].second){
      k++;
      if(k<n && a[k]<p[i].first) a[k] = p[i].first;
      else{
        ok = true;
        break;
      }
    }
    if(ok) break;
  }
  rep(i,n) ans += a[i];
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n,k,i;
  cin>>n;
  cin>>k;
  int x[n];
  for(i=0;i<n;i++){
    cin>>x[i];
  }
  int sum=0;
  for(i=0;i<n;i++){
    sum+=min(x[i],k-x[i]);
  }
  cout<<2*sum;
}

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

int main(){
    ll n;
    cin>>n;
    vector<string> s(n);
    for(ll i=0;i<n;++i){
        cin>>s[i];
    }
    ll m;
    cin>>m;
    vector<string> t(m);
    for(ll i=0;i<m;++i){
        cin>>t[i];
    }
    ll flag;
    ll ans=0;
    for(ll i=0;i<n;++i){
        flag=0;
        for(ll k=0;k<n;++k){
            if(s[i]==s[k]){
                flag++;
            }
        }
        for(ll j=0;j<m;++j){
            if(s[i]==t[j]){
                flag--;
            }
        }
        ans=max(ans,flag);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int ans = 0, N = 0;

void shichigosan(long now, bool shichi, bool go, bool san)
{
  if(now > N) { return; }
  if(shichi && go && san) { ans++; }
  shichigosan(now * 10 + 7, true, go, san);
  shichigosan(now * 10 + 5, shichi, true, san);
  shichigosan(now * 10 + 3, shichi, go, true);
  return;
}

int main(void)
{
  scanf("%d", &N);
  shichigosan(7, true, false, false);
  shichigosan(5, false, true, false);
  shichigosan(3, false, false, true);
  printf("%d", ans);
  return 0;
}

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

int main(){
    int A,B; cin >> A >> B;
    //floorメソッドは切捨て
    for (int i=1; i<=1000; i++){
        if (floor(i*0.08)==A && floor(i*0.1)==B){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1";
    return 0;
}

Measured memory_bytes: 768
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define MOD 1000000007
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define print(a, n) for(LL e=0; e<n; e++) cout<<a[e]<<" "; cout<<endl
#define read(a, n) for(LL e=0; e<n; e++) cin>>a[e];
using namespace std;

int main()
{
	fastio;
	LL n;
	cin>>n;
	LL a[n];
	read(a, n);

	LL ans = 0;
	map<int, int> m;

	for(int i=1; i<=n; i++){
		ans += m[i-a[i-1]];
		m[i+a[i-1]]++;
	}

	cout<<ans<<"\n";

	return 0;
}


Measured memory_bytes: 22176
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

typedef pair<int,int> pii;
const int INF = 1000000000;

int main(){
  while(true){
    int r,w,h,x,y,field[500][500];
    vector<pii> v[2];
    scanf("%d",&r);
    if(r==0) return 0;
    for(int k=0;k<2;k++){
      scanf("%d %d %d %d",&w,&h,&x,&y);
      for(int i=0;i<h;i++) for(int j=0;j<w;j++) scanf("%d",&field[i][j]);
      int level = 0, cnt = 0;
      priority_queue<pii,vector<pii>,greater<pii> > q;
      x--; y--;
      field[y][x] = 0;
      q.push(pii(1,w*y+x));
      q.push(pii(INF,0));
      while(true){
        pii p = q.top(); q.pop();
        if(p.first>level){
          v[k].push_back(pii(cnt,level));
          level = p.first;
          if(p.first==INF) break;
        }
        cnt++;
        int dx[] = {0,0,1,-1};
        int dy[] = {1,-1,0,0};
        for(int i=0;i<4;i++){
          int nx = p.second / w + dx[i], ny = p.second % w + dy[i];
          if(nx>=0&&nx<h&&ny>=0&&ny<w&&field[nx][ny]>0){
            q.push(pii(field[nx][ny],w*nx+ny));
            field[nx][ny] = 0;
          }
        }
      }
    }
    v[1].push_back(pii(INF,INF));
    int ans = INF;
    for(int i=0;i<v[0].size();i++){
      ans = min(ans,v[0][i].second+(*lower_bound(v[1].begin(),v[1].end(),pii(r-v[0][i].first,0))).second);
    }
    printf("%d\n",ans);
  }
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  cin.ignore();
  if(s=="ABC"){
    cout << "ARC" << endl;
    return 0;
  } else {
    cout << "ABC" << endl;
    return 0;
  }
  
  return 0;
}


Measured memory_bytes: 3588
package main

import (
	"fmt"
)

func main() {
	n := 0
	q := 0
	s := ""
	fmt.Scanf("%d %d", &n, &q)
	fmt.Scanf("%s", &s)

	m := make([]int, n+1)

	for i := 1; i < len(s); i++ {
		if s[i-1] == 'A' && s[i] == 'C' {
			m[i+1] = m[i] + 1
		} else {
			m[i+1] = m[i]
		}
	}
	//fmt.Printf("  A C A C T A C G\n")
	//fmt.Println(m)

	for i := 0; i < q; i++ {
		l := 0
		r := 0
		fmt.Scanf("%d %d", &l, &r)

		fmt.Println(m[r] - m[l])
	}
}


Measured memory_bytes: 6884
import numpy as np
(n,m),*d = [list(map(int, s.split())) for s in open(0)]

inf = 100000000
dp = np.full([2]*n, inf, dtype=np.int)
dp[tuple([0]*n)] = 0

for i in range(m):
    a = d[2*i][0]
    b = d[2*i][1]
    c = d[2*i+1]
    
    l0 = [slice(None)]*n
    for x in c:
        l0[x-1] = slice(None,1)
    dp = np.minimum(dp, dp[tuple(l0)]+a)
    
ans = dp[tuple([1]*n)]
if ans == inf:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 12644
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

s = read()
if 'AC' in s:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 6480
N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9+7
nums = A[:]
nums_sorted = sorted(nums)
rank = {}
count = 0
for n in nums_sorted:
    if not n in rank:
        rank[n] = count
        count += 1
    else:
        count += 1
#print(rank)

def count_inversion(sequence):
    count = 0
    ret = [0] * len(sequence)
    for i in range(1,len(sequence),1):
        for j in range(i,len(sequence),1):
            if sequence[i-1] > sequence[j]:
                ret[i-1] += 1
    return ret
rev = count_inversion(nums)

#print(rev)
ans = 0
n = K
for a, d in zip(rev, nums):
    ans += n*(2*a + (n-1)*rank[d])//2 % MOD
print(ans% MOD)


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
ll divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  // sort(res.begin(), res.end());
  return res.size();
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  ll ans=0;
  reps(i,n){
    ll sum=0;
    for(ll j=1; i*j<=n; j++){
      sum+=j;
    }
    // cout<<i<<' '<<sum<<endl;
    ans+=i*sum;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 1; i <= (int)(n); i++)

int showAll(vector<int> v) {
  for (int i = 0; i < v.size(); i++) {
    cout << v[i] << " ";
  }
  cout << endl;
  return 0;
}

int main() {
  int n, k;
  cin >> n >> k;
  double first = 0;
  if (n >= k) {
    first = (n - k + 1) / (double)n;
  }
  // cout << first << endl;
  int loop = min(n, k - 1);
  rep (i, loop) {
    int count = 1;
    int num = i * 2;
    while (num < k) {
      count++;
      num *= 2;
    }
    first += (double)1 / (pow(2, count) * n);
    // cout << i << ": " << first << endl;
  }
  printf("%.10f\n", first);

  return 0;
}



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

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    if ((10*g + b) % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<vector>
#include<list>
#include<stdio.h>
#include<math.h>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int main(){
    int wsum = 0, ksum = 0;
    int inp;
    vector<int> w, k;
    rep(i,10){
        cin >> inp;
        w.push_back(inp);
    }
    rep(i,10){
        cin >> inp;
        k.push_back(inp);
    }
    sort(w.begin(), w.end(), greater<int>());
    sort(k.begin(), k.end(), greater<int>());
    rep(i, 3){
        wsum+= w[i];
        ksum+= k[i];
    }
    cout << wsum << ' ' << ksum << endl;
}

Measured memory_bytes: 1216
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int count = 0;
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		int d = sc.nextInt();
		int a = r / d;
		int b = l / d;
		if (l % d == 0) {
			b--;
		}
		System.out.println(a-b);
	}
}


Measured memory_bytes: 35616
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int r = 0;
                int b = 0;
                for (int i = 0 ; i< s.length(); i++) {
                    if (s.substring(i, i + 1).equals("R")) {
                        r++;
                    } else {
                        b++;
                    }
                }
                
                if (r > b) {
                    System.out.println("Yes");
                } else {
                    System.out.println("No");
                }
                    
    }

}


Measured memory_bytes: 23892
#include<algorithm>
#include<cassert>
#include<climits>
#include<cmath>
#include<cstring>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << endl

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-8;

const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

void dfs(int v, int n, vector<int>& c, const vector< vector<int> >& g){
    c[v] = n;

    for(auto to : g[v]){
        if(c[to] == -1){
            dfs(to, n ^ 1, c, g);
        }
    }

    return;
}

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

    int n, m;
    while(cin >> n >> m, n){
        vector< vector<int> > g(n);
        rep(i, m){
            int u, v;
            cin >> u >> v;
            g[--u].emplace_back(--v);
            g[v].emplace_back(u);
        }

        vector<int> c(n, -1);
        dfs(0, 0, c, g);

        bool flag = true;
        rep(i, n){
            for(auto to : g[i]){
                if(c[i] == c[to]){
                    flag = false;
                    break;
                }
            }
        }

        if(!flag){
            cout << 0 << endl;
            continue;
        }

        vector<int> cnt(2);
        rep(i, n){
            ++cnt[c[i]];
        }

        set<int> ans;
        rep(i, 2){
            if(cnt[i] % 2 == 0){
                ans.insert(cnt[i] / 2);
            }
        }

        cout << ans.size() << endl;
        for(auto x : ans){
            cout << x << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3216
n = int(input())
s = input()
ans = [s[1:].count('E')]

for i in range(1, n):
    num = ans[i - 1]
    if s[i - 1] == 'E':
        num -= 1
    if s[i] == 'W':
        num += 1
    ans.append(num)

print(min(ans))

Measured memory_bytes: 15564
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define inf 40000000007
#define eps 1e-8
#define PI 3.14159265359
#define sp printf(" ")
#define vi vector<int>
#define vl vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pcc pair<char, char>
#define mp make_pair
#define FF first
#define SS second
#define pb(x) push_back(x)
#define sd(x) scanf("%d", &(x))
#define pd(x) printf("%d", (x))
#define pdn(x) printf("%d\n", (x))
#define sld(x) scanf("%ld", &(x))
#define pld(x) printf("%ld", (x))
#define pldn(x) printf("%ld\n", (x))
#define slf(x) scanf("%lf", &(x))
#define plf(x) printf("%.9lf", (x))
#define plfn(x) printf("%.8lf\n", (x))
#define sch(x) scanf("%c", &(x))
#define pch(x) printf("%c", (x))
#define pchn(x) printf("%c\n", (x))
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define ios ios::sync_with_stdio(false); cin.tie(0) ; cout.tie(0)
#define endl '\n'
using namespace std;
#define N 1000006
#define M 100006
#define T 300001
int v[1000];
int pre[T];
int main()
{
    ios;
    int n;
    cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        int ans1=1;
        for(int j=0;j<=20;j++)
        {
            if((x&(1<<j)))
            {
                ans1=max(ans1,v[j]+1);
                v[j]=i;
            }
        }
        pre[i]=max(pre[i-1],ans1);
        ans+=(ll)(i-pre[i]+1);
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 1152
import java.io.*;
import java.util.*;
public class Main
{
	public static void main(String[]args)
	{
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		int a = sc.nextInt();
		int b = sc.nextInt();
		String c = sc.next();
		if (c.equals(s))
			a--;
		else
			b--;
		System.out.println(a + " " + b);
	} 
}


Measured memory_bytes: 20948
while(1):
    n,x = [int(i) for i in input().split()]
    if n == 0 and x == 0:
        break
    count = 0
    for i in range(1,n+1):
        for j in range(1,n+1):
            for k in range(1,n+1):
                if i < j < k and i + j + k == x:
                    count += 1
    print(count)




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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,ans,f[4010][4010],c[4010][4010],p=998244353;
void ycl(){
	ll i,j;
	f[0][0]=1;
	for(i=1;i<=4000;i++) 
	 for(j=0;j<=4000;j++){
	 	f[i][j]=f[i-1][j];
	 	if(j>0)f[i][j]=(f[i][j]+f[i][j-1])%p;
	 }
	for(i=0;i<=4000;i++)c[i][0]=1;
	for(i=1;i<=4000;i++)
	 for(j=1;j<=i;j++)c[i][j]=(c[i-1][j]+c[i-1][j-1])%p;
}
int main(){
	ll mn,mx,len,i,j,now;
	ycl();
	scanf("%lld%lld",&m,&n);
	//prllf("%d\n",f[m][n]);
	for(i=2;i<=m*2;i++){
		ans=0;
		mn=max(1ll,i-m);
		mx=i/2;
		len=mx-mn+1;
		//prllf("%d %d\n",i,len);
		for(j=0;j<=len;j++){
			if(j*2>n)break;
			now=c[len][j]*f[m][n-j*2]%p;
			if(j%2==0)ans=(ans+now)%p;
			 else ans=(ans-now+p)%p;
		}
		printf("%lld\n",ans);
	}
}
/*
直接容斥有几对不合法容斥系数是假的
考虑到i+j的时候i和j不能同时出现，那么我们就容斥i和j不合法的对数 （虽然这样只是看上去感觉挺对的样子==） 
*/

Measured memory_bytes: 249600
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {    public static void main(String[] args) {
    int aValue;
    int bValue;
    int answer;

    Scanner scanner = new Scanner(System.in);

    String A = scanner.next();
    String B = scanner.next();

    aValue = Integer.valueOf(A);
    bValue = Integer.valueOf(B);

    if (bValue % aValue == 0) {
       answer = bValue + aValue ;
    } else {
        answer = bValue - aValue;
    }
    System.out.println(answer);

    }
}


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

int main() {
    std::string s;
    std::cin >> s;
    auto sz = s.size();
    auto c = 0;
    for (auto i = 0; i < sz / 2; ++i)
        c += s[i] != s[sz - i - 1];
    std::cout << c;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
vector<int> road[100000];

int main() {
	int N, M, tmp, ans;
	ans = 0;
	vector<int> H;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		H.push_back(tmp);
	}
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		road[a - 1].push_back(b - 1);
		road[b - 1].push_back(a - 1);
	}
	for (int i = 0; i < N; i++) {
		if (road[i].size() == 0)ans++;
		else {
			int flag = 1;
			for (int j = 0; j < road[i].size(); j++) {
				if (H[i] <= H[road[i][j]])flag = 0;
			}
			if (flag == 1)ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8724
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;

  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }

  int maxs = 0;
  int right = 0;
  int sum = 0;
  int l, r;
  for (int left = 0; left < n; left++) {
    while (right < n && right < k + left) {
      sum += p.at(right);
      right++;
    }

    if (sum > maxs) {
      maxs = sum;
      l = left;
      r = right-1;
    }

    if (right == left) right++;
    else sum -= p.at(left);

  }

  double ans = 0;
  for (int i = l; i <= r; i++) {
    double x = p.at(i);
    double a = x*(x+1)/2/x;
    ans += a;
  }
  cout << fixed << setprecision(10) << ans << endl;

}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int a = 0;
    string s , t;
    cin >> s >> t;
    if (s[0] == t[0]){
        a++;
    }
    if (s[1] == t[1]){
        a++;
    }
    if (s[2] == t[2]){
        a++;
    }
    cout << a;
    return 0;
}


Measured memory_bytes: 3564
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var X = Console.ReadLine();

            var fn = new int[N + 1];
            fn[1] = 1;
            for (int i = 2; i <= N; i++)
            {
                var temp = i % popcount(i);
                fn[i] = fn[temp] + 1;
            }

            var count1 = X.Length - X.Replace("1", "").Length;
            var modPlus = 0;
            var modMinus = 0;
            var modp = 1;
            var modm = 1;
            for (int i = N - 1; i >= 0; i--)
            {
                if (X[i] == '1')
                {
                    modPlus += modp;
                    modPlus %= count1 + 1;
                    if (count1 > 1)
                    {
                        modMinus += modm;
                        modMinus %= count1 - 1;
                    }
                }
                modp = (modp * 2) % (count1 + 1);
                if (count1 > 1)
                    modm = (modm * 2) % (count1 - 1);
            }
            var Xi = new int[N];
            modp = 1;
            modm = 1;
            for (int i = N - 1; i >= 0; i--)
            {
                if (X[i] == '1')
                {
                    if (count1 > 1)
                    {
                        if (modMinus - modm < 0) modMinus += count1 - 1;
                        Xi[i] = fn[(modMinus - modm) % (count1 - 1)] + 1;
                    }
                    else
                    {
                        Xi[i] = 0;
                    }
                }
                else
                {

                    if (modPlus - modp < 0) modPlus += count1 + 1;
                    Xi[i] = fn[(modPlus + modp) % (count1 + 1)] + 1;
                }
                modp = (modp * 2) % (count1 + 1);
                if (count1 > 1)
                    modm = (modm * 2) % (count1 - 1);
            }
            Console.WriteLine(string.Join("\n", Xi));
        }


        static int popcount(int X)
        {
            var result = 0;
            while (X > 0)
            {
                if ((X % 2) == 1) result++;
                X /= 2;
            }
            return result;
        }
    }
}


Measured memory_bytes: 32612
#include <stdio.h>
char RideBack[9][9],T[6],ans[4]={'L','U','R','D'};int a[4][2]={-1,0,0,-1,1,0,0,1};bool OK=true;
void dfs(int x, int y, int w, int deep) {if (deep) printf("%c",ans[w]);if (!x && !y && deep) OK=false;for (int j=(w+3)&3;OK;j=(j+1)&3) {int n_x=x+a[j][0],n_y=y+a[j][1];if (n_x>=0 && n_x<9 && n_y>=0 && n_y<9 && RideBack[n_y][n_x]=='1') dfs(x+a[j][0]*2,y+a[j][1]*2,j,deep+1);}}
int main() {int i,j,k;for (i=0;i<9;i++) {scanf("%s",&T);if (i&1) for (k=0,j=0;j<5;RideBack[i][k]=T[j++],k+=2); else for (k=1,j=0;j<4;RideBack[i][k]=T[j++],k+=2);}dfs(0,0,1,0);puts("");return 0;}

Measured memory_bytes: 0
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>

//#include <bits/stdc++.h>
using namespace std;
using LL = int;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000][10000], a[2000000], b[2000000];
string str, ss;
bool f[1100][1100];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
vector<Edge>vec[200000];
vector<LL>v,pick[200000];
map<string, vector<LL>>ma;
multiset<LL>st[3];
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
LL partf(LL n, LL k) {
	if (k == 0 && n == 0)return 1;
	if (k <= 0 || n < 0)return 0;
	//dp=-1で初期化
	if (dp[n][k] != -1)return dp[n][k];
	dp[n][k] = (partf(n, k - 1) + partf(n - k, k)) % MOD;
	return dp[n][k];
}

int main() {
	cin >> n >> m;
	rep(i, n+1)rep(j, m+1)dp[i][j] = -1;
	cout << partf(n,m)<< endl;
	return 0;
}



Measured memory_bytes: 20456
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int n, ans = 0;
  deque<char> d;
  string s;
  cin >> n;
  cin >> s;
  for (int i = 0; i < n; i++) {
    d.push_back(s[i]);
  }
  while (!d.empty()) {
    while (!d.empty() && d[0] == 'R') {
      d.pop_front();
    }
    while (!d.empty() && d.back() == 'W') {
      d.pop_back();
    }
    if (d.empty()) {
      break;
    }
    if (d[0] == 'W' && d.back() == 'R') {
      ans++;
      d.pop_front();
      d.pop_back();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3832
N=int(input())
L=list(map(int,input().split()))
wa=sum(L)
m=abs(wa-2*L[0])
s=wa-2*L[0]
for j in range(1,N-1):
  s-=2*L[j]
  n=abs(s)
  m=min(m,n)
print(m)
  

  


Measured memory_bytes: 38256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main(int argc, char** argv) {

        int N;
        long long K;
        long long* x;
  		long long k;

        cin >> N >> K;
        x = (long long *) malloc(sizeof(long long)*N);
        for(int cnt0 = 0; cnt0 < N; cnt0++){
                cin >> *(x+cnt0);
        }

        if(K == 0) {
                long long ret = 0;
                for(int cnt0=0; cnt0 < N; cnt0++){
                        ret += *(x+cnt0);
                }
                printf("%lld", ret);
                return 0;
        }
  
        int p;
        p = log2(K);
		long long num = 0;
  
  		k = K;
        while(p > -1){
                int idx=0;
                for(int cnt0 = 0; cnt0 < N; cnt0++){
                        if(*(x+cnt0) & (1LL << p)) idx++;
                }
          
          		bool flag;
                if(idx > N-idx) flag = false;
                else flag = true;
                long long ex2 = pow(2,p);
		        if(flag && num + ex2 <= K){
                        num += ex2;
                  		k -= ex2;
                }
          		p--;
        }

//        printf("%lld\n", num);
  		long long sum = 0;
        for(int cnt0 = 0; cnt0 < N; cnt0++){
                sum += num ^ *(x+cnt0);
        }

        printf("%lld", sum);
        return 0;
}


Measured memory_bytes: 1024
class Main {
    public static void main(String[] args)  {
        java.util.Scanner sc = new java.util.Scanner(System.in);
        int N = Integer.parseInt(sc.next()),  A = Integer.parseInt(sc.next()), B = Integer.parseInt(sc.next()), times = 0, i, t = N / 3;
        java.util.List<Integer> P = new java.util.ArrayList<>();
        for(i = 0; i < N; i++) P.add(Integer.parseInt(sc.next()));
        for(int j = 0; j < t; j++) {
            for(i = 0; i < N; i++) {
                if(P.get(i) <= A) {
                    P.remove(i);
                    break;
                }
            }
            if(i == N--) break;
            for(i = 0; i < N; i++) {
                int tmp = P.get(i);
                if(A+1<=tmp&&tmp<=B) {
                    P.remove(i);
                    break;
                }
            }
            if(i == N--) break;
            for(i = 0; i < N; i++) {
                if(B+1<=P.get(i)) {
                    P.remove(i);
                    break;
                }
            }
            if(i == N--) break;
            times++;
        }
        System.out.println(times);
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <ctime>
using namespace std;

int N,M; vector<int> a,b;
void input()
{
    cin >> N >> M;
    a.resize(M), b.resize(M);
    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }
}

void solve()
{
    
    int ans = 0;
    for (int i = 0; i < M; ++i) {
        vector<vector<int>> G(N);
        for (int j = 0; j < M; ++j){
            if(i==j) continue;
            G[a[j]].emplace_back(b[j]);
            G[b[j]].emplace_back(a[j]);
        }

        vector<bool> is_checked(N,false);
        queue<int> que; que.push(0);
        while(!que.empty()){
            int v = que.front(); que.pop();
            is_checked[v] = true;
            for (auto nv: G[v]){
                if(is_checked[nv]) continue;
                que.push(nv);
            }
        }

        for(auto is: is_checked){
            if(!is){
                ++ans; break;
            }
        }
    }

    cout << ans << endl;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    // int ti = clock();
    input();
    solve();
    // printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <climits>
#include <cmath>
using namespace std;
vector<int> dp;
vector<int> h;
int N;

void input() {
    cin >> N;
    dp.resize(N);
    h.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> h.at(i);
    }    
}
int solve() {
    if(N == 2) {
      return abs(h.at(1) - h.at(0));
    }
    for(int i = 0; i < N; i++) {
      dp.at(i) = INT_MAX;
    }
    dp.at(0) = 0;
    dp.at(1) = abs(h.at(1) - h.at(0));
    for(int i = 2; i < N; i++) {
        dp.at(i) = min(dp.at(i-1) + abs(h.at(i) - h.at(i-1)), dp.at(i-2) + abs(h.at(i) - h.at(i-2)));
    }
    return dp.at(N-1);
}
int main() {
    input();
    cout << solve() << endl;
}

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

int main() {
  double x,y;
  cin >> x >> y;
  double r=(x+y)/2;
  if(abs(x-r)>90||abs(y-r)>90) {
    r+=180;
    if(r>=360) r-=360;
  }
  printf("%.10f\n",r);
  return 0;
}


Measured memory_bytes: 3280
#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()
{
    string s, t;
    cin >> s >> t;
    if (s==t.substr(0, s.size())) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define mp make_pair

typedef std::pair<int, int> pii;

void get_ans(int n, int z, int w)
{
    int dk[n + 1];
    dk[0] = w;
    for (int i = 0; i < n; ++i)
        scanf("%d", dk + i + 1);
    int ans[2][n];
    for (int i = n - 1; i >= 0; --i)
    {
        ans[0][i] = 0;
        ans[1][i] = 1000000000;
        for (int k = i + 1; k < n; ++k)
        {
            ans[0][i] = std::max(ans[0][i], ans[1][k]);
            ans[1][i] = std::min(ans[1][i], ans[0][k]);
        }
        ans[0][i] = std::max(ans[0][i], std::abs(dk[n] - dk[i]));
        ans[1][i] = std::min(ans[1][i], std::abs(dk[n] - dk[i]));                
    } 
    printf("%d\n", ans[0][0]);
}

int main()
{
    int n, z, w;
    while (scanf("%d %d %d", &n, &z, &w) == 3)
        get_ans(n, z, w);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;

struct edge{int from, to; ll cost;};
const ll inf = 1e18;
int n,m; ll p;
vector<edge> g;
ll dist[2505];

int main(){
    cin >> n >> m >> p;
    rep(i, m){
        int f,t; ll c; cin >> f >> t >> c; f--; t--; c -= p;
        g.push_back(edge{f, t, -c});
    }

    rep(i,n) dist[i] = inf;
    dist[0] = 0;
    
    rep(i, n){
        rep(j, m){
            edge e = g[j];
            if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
            }
        }
    }

    vector<bool> negative(n, false);
    rep(i,n){
        rep(j,m){
            edge e = g[j];
            if (dist[e.from] != inf && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                negative[e.to] = true;
            }
            if(negative[e.from]) negative[e.to] = true;
        }
    }

    if(negative[n-1]) cout << "-1" << endl;
    else cout << max(-dist[n-1], 0LL) << endl;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll N, K, S;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> K >> S;
    vector<ll> ans(N);
    rep(i,N) ans[i] = S+1;
    rep(i,K) ans[i] = S;
    if (S == 1000000000) {
        rep(i,N) ans[i] = 1;
        rep(i,K) ans[i] = S;
    }
    rep(i,N) cout << ans[i] << " ";
    cout << endl;
}

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

#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi 3.14159265

using namespace std;
#define prime 1000000007

const ll N = 300005;

#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";

int n, c, p, ans;
ii v[200100];

string s;

int ce(int a, int b){
	return (a+b-1)/b;
}

int main(){
	cin >> n >> s;

	for (int i = 0; i < n; ++i){
		if(s[i] == '#') {
			c++;
		}
		v[i].ff = c;
	}

	for (int i = n-1; i >= 0; --i){
		if(s[i] == '.') {
			p++;
		}
		v[i].ss = p;
	}

	int ans = 200100;
	for (int i = 0; i < n; ++i){
			ans = min(ans, v[i].ff + v[i].ss);		
	}

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

Measured memory_bytes: 2180
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

template <typename T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
    for (T& x: vec) { is >> x; }
    return is;
}

int main() {
	ll ans = 0;
	ll tmp;
	int n; cin >> n;
	int a[n] = {}, b[n]={};
	REP(i, n) a[i] = 20000 * (i+1);
	REP(i, n) b[i] = 20000 * (n-i);
	REP(i, n){
		cin >> tmp;
		a[tmp-1] += i;
	}
	REP(i, n) cout << a[i] << " ";
	cout << endl;
	REP(i, n) cout << b[i] << " ";
	cout << endl;
	//cout << ans << endl;
}

Measured memory_bytes: 3752
q, h, s, d = gets.split.map(&:to_i)
n = gets.to_i

q4 = q*4
h2 = h*2


mina = [q4,h2,s].min
if n%2 == 0
	puts [mina*n, n/2*d].min
else
	puts [mina*n, n/2*d+mina].min
end 

Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main(){
char c ;
cin >> c ;
if(c == 'a' || c == 'e' || c== 'i' || c == 'u' || c== 'o' )
    cout << "vowel "<< endl ;
else
    cout << "consonant " << endl ;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>	
#define int long long int
using namespace std;
double dp[3010][3010];
main()
{	
	int n,k;
	cin>>n;
	double arr[n+1], ans=0;
	for(int i=1;i<=n;i++)
		cin>>arr[i];
	k=(n+1)/2;
	double var=1;
	for(int i=1;i<=n;i++){
		var*=1-arr[i];
		dp[i][0]=var;
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=k;j++){
			dp[i][j]=dp[i-1][j]*(1-arr[i])+dp[i-1][j-1]*arr[i];
		}
	}
	for(int i=0;i<k;i++)
		ans+=dp[n][i];
	cout<<setprecision(12)<<fixed<<1-ans;
}

Measured memory_bytes: 69760
import heapq
N,M=map(int, input().split())
X=sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x:x[0])

a=[]
ans, j = 0, 0

for i in range(1, M + 1):
  #M-1~Mから0~MまでのM日間について後ろから考える
  while (j < N) and (X[j][0] <= i):
    #i=1　1日で報酬が受け取れるものを取り出し最大の物をプラス　2日以内で報酬が…の繰り返し
    heapq.heappush(a, -X[j][1])  
    j += 1
  if len(a):
    ans += -heapq.heappop(a)  
    
print(ans)

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

bool solve(int a[], int m, int n)
{
    if (m == 0)
        return true;
    if (n == 0)
        return false;
    return solve(a, m, n - 1) | solve(a, m - a[n - 1], n - 1);
}

int main()
{
    int n, q;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    int m;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        cin >> m;
        cout << (solve(a, m, n) ? "yes" : "no") << endl;
    }
}



Measured memory_bytes: 3108
#include <iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
#define loop(i,n) for(int i = 0; i < (n); i++)
#define loops(i,f,n) for(int i = (f); i < (n); i++)
#define INF 1e9
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b)cout<<"a == b"<<endl;
    else cout<<(a>b?"a > b":"a < b")<<endl;
}


Measured memory_bytes: 3096
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PI acos(-1)
typedef long long int ll;
typedef long double ld;

int main(void) {
  ll    answer;
  int   scan;
  ll    n;
  char  *s;
  answer = 0;
  scan = scanf("%lld", &n);
  s = (char *)malloc(sizeof(char) * (n + 1));
  scan = scanf("%s", s);

  ll    w;
  ll    r;
  ll    len;
  w = 0;
  r = 0;
  len = 0;
  while (s[len] != '\0') {
    if (s[len] == 'R') {
      r++;
    }
    if (s[len] == 'W') {
      w++;
    }
    len++;
  }

  ll    c;
  c = 0;
  while (c < len && r > 0) {
    if (s[c] == 'W') {
      r--;
      answer++;
    } else {
      r--;
    } 
    c++;
  }
  
  printf("%lld", answer);
  return (0);
}


Measured memory_bytes: 1892
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

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

Measured memory_bytes: 3628