akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#define Mod 1000000007
#define INF 1e14
typedef long long int ll;
const ll N=1e6+5;
bool x[N+1]={false};
ll fast(ll n,ll a)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a)%Mod;
        if(n%2==0)
        {
            return (((res%Mod)*(res%Mod))%Mod);
        }
        else{
            return (((((res%Mod)*a)%Mod)*res)%Mod);
        }
    }
}
int main()
{
  ll n,i;
  cin>>n;
  ll a[n];
  for(i=0;i<n;i++)
  {
      cin>>a[i];
  }
  ll x=0;
  for(i=0;i<n;i++)
  {
      if(i%2==0)
        x+=a[i];
      else
        x-=a[i];
  }
  vector<ll> vec;
  vec.push_back(x);
  ll r=x/2;
  for(i=0;i<n-1;i++)
  {
      vec.push_back(2*(a[i]-r));
      r=a[i]-r;
  }
  for(i=0;i<vec.size();i++)
    cout<<vec[i]<<" ";
}


Measured memory_bytes: 3060
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::min;

fn main() {
    input!{
        n: usize,
        v: [usize; n]
    }
    let mut dp: Vec<[usize; 4]> = vec![[0, 0, 0, 0]; n + 1];
    let v_o: Vec<usize> = v.iter().clone().map(|x| (x + 1) % 2).collect();
    let v_e: Vec<usize> = v.iter().clone().map(|x| if *x == 0 { 2 } else { x % 2 }).collect();
    for i in 0..n {
        dp[i + 1][0] = dp[i][0] + v[i];
        dp[i + 1][1] = min(dp[i][0], dp[i][1]) + v_e[i];
        dp[i + 1][2] = min(min(dp[i][0], dp[i][1]), dp[i][2]) + v_o[i];
        dp[i + 1][3] = min(min(dp[i][0], dp[i][1]), min(dp[i][2], dp[i][3])) + v_e[i];
    }
    let total = dp[n][0];
    println!("{}", dp.iter().map(|x| min(min(x[0], x[1]), min(x[2], x[3])) + total - x[0]).min().unwrap());
}


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

using namespace std;

#define MAX_V 100000
#define INF 1e9
typedef pair<int,int> pii;

struct edge{
  int to,d;
};

int V,E;
int weight[MAX_V];
vector<edge> G[MAX_V];

void dijkstra(int r){
  priority_queue<pii,vector<pii>,greater<pii> > Q;
  Q.push(pii(0,r));
  weight[r] = 0;
  while(!Q.empty()){
    pii p = Q.top(); Q.pop();
    int v = p.second;
    if(weight[v] < p.first){ continue; }
    for(int i = 0 ; i < (int)G[v].size() ; i++){
      edge &e = G[v][i];
      if(weight[v] + e.d < weight[e.to]){
        weight[e.to] = weight[v] + e.d;
        Q.push(pii(weight[e.to],e.to));
      }
    }
  }
}

void init(){
  for(int i = 0 ; i < MAX_V ; i++){
    G[i].clear();
    weight[i] = INF;
  }
}

int main(){
  int r,s,t,d; init();
  cin >> V >> E >> r;
  for(int i = 0 ; i < E ; i++){
    cin >> s >> t >> d;
    G[s].push_back((edge){t,d});
  }
  dijkstra(r);
  for(int i = 0 ; i < V ; i++){
    if(weight[i] == INF){
      cout << "INF" << endl;
    }else{
      cout << weight[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 11308
n, k = map(int, input().split())
A = [int(input()) for i in range(n)]
A = [a-k for a in A]

from itertools import accumulate
C = [0]+A
C = list(accumulate(C))
#print(C)

class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(self.n+1) # 1-indexed

    def init(self, init_val):
        for i, v in enumerate(init_val):
            self.add(i, v)

    def add(self, i, x):
        i += 1 # to 1-indexed
        while i <= self.n:
            self.bit[i] += x
            i += (i & -i)

    def sum(self, i, j):
        # return sum of [i, j)
        return self._sum(j) - self._sum(i)

    def _sum(self, i):
        # return sum of [0, i)
        res = 0
        while i > 0:
            res += self.bit[i]
            i -= i & (-i)
        return res

B = list(set(C))
B.sort(reverse=True)
D = {}
for i, b in enumerate(B):
    D[b] = i

C = [D[c] for c in C]
bit = BIT(max(C)+1)
ans = 0
for c in C:
    ans += bit.sum(c, bit.n)
    bit.add(c, 1)
print(ans)

Measured memory_bytes: 170016
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <set>
//#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(true);
    char a[3];
    cin>>a;
    if(strlen(a)==2)
        cout<<a;
    else
    {
        for(int i = strlen(a)-1 ; i >=0;--i)
            cout<<a[i];
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int k;
  int cnt = 0;
  int ans;
  
  cin >> s >> k;

  for(int i = 0;i < s.size();i++){
    if(s[i] != '1'){
      ans = s[i] - '0';
      break;
    }
    cnt ++;
  }
  
  if(cnt < k){
    cout << ans << endl;
  }else{
    cout << 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<iomanip>
using namespace std;
int n,m,cnt;
char s[3005],t[3005];
int dp[3005][3005],st[3005];
int main() 
{
	scanf("%s%s",s+1,t+1);
	n=strlen(s+1);
	m=strlen(t+1);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
			dp[i][j]=max(dp[i][j],dp[i-1][j-1]);
			if(s[i]==t[j])
			{
				if(dp[i][j]<dp[i-1][j-1]+1)
				{
					dp[i][j]=dp[i-1][j-1]+1;
				}
			}
		} 
	}
	while(dp[n][m])
	{
		if(dp[n][m-1]==dp[n][m])
			m--;
		else
		{
			if(dp[n-1][m]==dp[n][m])
			{
				n--;
			}
			else
			{
				st[++cnt]=n;
				n--,m--;
			}
		}
	}
	while(cnt)
	{
		cout<<s[st[cnt]];
		cnt--;
	}
	//printf("%d",dp[n][m]);
	return 0;
}


Measured memory_bytes: 35584
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(15).
        01 B PIC 9(15).
        01 C PIC ZZZZZZZ.
      	01 t PIC 9(15).
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
        01 N PIC 9(15).
      
        PROCEDURE DIVISION.
      	MAIN.
			ACCEPT A.
      		ACCEPT B.
      		COMPUTE C = 6 - A - B.
			DISPLAY C.
		STOP RUN.

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
using namespace std;

vector <int> ans;

void solve(string s);

int main(){
string S; cin>>S;
int N = S.size();

S += "##";
string s; 

for(int i=0;i<N;i++){
  if(S[i] == 'L' and S[i+1] != 'L') {s += S[i]; solve(s); s = "";continue;}
  s += S[i];
}

for(int i=0;i<ans.size();i++){
  if(i == ans.size() - 1){ cout<<ans[i];break;}
  cout<<ans[i]<<' ';
}
  return 0; 
}

void solve(string s){
  int r = 0;
  int l = 0;

  for(int i=0;i<s.size();i++){
    if(s[i] == 'R') r++;
    else l++;
  }

  int half_r = r/2;
  int half_l = l/2;

  int L = half_r + (l - half_l);
  int R = half_l + (r - half_r);

  for(int i=0;i<s.size();i++){

    if(s[i] == 'R' and s[i+1] == 'L'){ ans.push_back(R); continue;}
    if(s[i-1] == 'R' and s[i] == 'L') {ans.push_back(L); continue;}

    ans.push_back(0);


  }



}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int gcd(int x,int y){return (y==0?x:gcd(y,x%y));}
signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int a, b, c; cin >> a >> b >> c;

  YES(c%gcd(a,b)==0);

    return 0;
}


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

int n;
int a[1000001];
signed main() 
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=2;i<=n;i++)
		if(a[i]==a[i-1])
		{
			printf("NO");
			return 0;
		}
	printf("YES");
	return 0;
}


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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    int AB = A * B, CD = C * D;

    if (AB < CD) {
        cout << CD << endl;
    }
    else {
        cout << AB << endl;
    }
}

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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;

int main(void){

  ll A,B,C,D;
  cin >> A >> B >> C >>D;
  
  while(A>0 && C>0){
    C-=B;
    A-=D;
  }
  
  if(C<=0 && D<=0){
    cout << "Yes";
  }else if(C<=0){
    cout << "Yes";
  }else{
    cout << "No";
  }

  return 0;
}

Measured memory_bytes: 3600
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        int count = 0;
        for (int i = 1; i < n - 1; i++) {
            if (array[i-1] < array[i]) {
                if (array[i] < array[i+1]) {
                    count++;
                }
            } else {
                if (array[i] > array[i+1]) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}


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

#define MAX_N 100

int ps[MAX_N];
int dp[MAX_N][76];

int main() {
  int n;

  std::cin >> n;

  for(int i = 2; i <= n; ++i) {
    int temp = i, p = 0;
    for(int j = 2;; j += 2) {
      while(temp % j == 0 && temp > 1) {
          ++ps[p];
          temp /= j;
      }
      if(temp == 1) break;
      if(j == 2) --j;
      ++p;
    }
  }

  for(int j = 1; j < 76; ++j) {
    dp[0][j] = (ps[0] >= j - 1) ? 1 : 0;
  }
  for(int i = 1; i < n; ++i) {
    for(int j = 1; j < 76; ++j) {
      for(int ni = 0; ni <= ps[i]; ++ni) {
        if(j % (ni + 1) == 0) dp[i][j] += dp[i - 1][j / (ni + 1)];
      }
    }
  }

  std::cout << dp[n - 1][75] << std::endl;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    int cnt = 0;
    rep(i, n) {
        if (a[i] <= 0) ++cnt;
    }
    ll sum = 0;
    rep(i, n) sum += abs(a[i]);
    if (cnt%2==1) {
        int m = INF;
        rep(i, n) m = min(m, abs(a[i]));
        sum -= 2 * m;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a,b,sum=0,sumb=0;
    string s;
    cin>>n>>a>>b>>s;
    rep(i,s.size()){
        if(s[i]=='a'){
            if(sum<a+b){
                cout<<"Yes"<<endl;
                sum++;
            } else{
                cout<<"No"<<endl;
            }
        }
        else if(s[i]=='b'){
            if(sum<a+b&&sumb<b){
                cout<<"Yes"<<endl;
                sum++;sumb++;
            } else{
                cout<<"No"<<endl;
            }
        } else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

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

typedef long long ll;
const ll InF = 1e15;

ll GCD(ll a, ll b) {
  return b ? GCD(b ,a%b) : a;
}

int main() {
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   ll e = c * d / GCD(c,d);;
   ll res1 = (a - 1) / c + (a - 1) / d - (a - 1) / e;
   ll res2 = b / c + b / d - b / e;
   ll res = res2 - res1;
   ll ans = b - a + 1 - res;
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
n=int(input())
l=[float(i) for i in input().split()]
l.sort()
while len(l)>1:
    # print(l)
    a,b=l[0],l[1]
    av=(a+b)/2
    del l[0]
    del l[0]
    l.append(av)
    l.sort()
print(l[0])

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;
int main(){
  ll c[3][3];
  for(ll i=0;i<3;i++){
    for(ll j=0;j<3;j++){
      cin >>c[i][j];
    }
  }
  ll y=c[0][0]+c[1][1]+c[2][2];
  if(c[0][0]+c[2][2]==c[0][2]+c[2][0]){
    if(c[0][1]+c[1][0]+c[2][2]==y){
      if(c[0][0]+c[1][2]+c[2][1]==y){
        cout <<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout <<"No"<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可
//乗算の際にオーバーフローに注意せよ！！（適切にmodをとれ）
//制約をよく読め！

const ll INF=1e18;

int main() {
    // 頂点数と辺数
    int N, M; cin >> N;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    V<ll> ans(N);
    V<int> deg(N);
    priority_queue<ll> pq;
    ll cnt=0;
    M=N-1;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        G[--a].push_back(--b);
        G[b].push_back(a);
        deg[a]++;
        deg[b]++;
    }
    rep(i,N){
        ll c;
        cin>>c;
        pq.push(c);
    }

    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    int s;//sは出発点、tは目的地 入力等をちゃんと行え
    rep(i,N){
        if(deg[i]==1){
            s=i;
            break;
        }
    }

    // 初期条件 (頂点 s を初期ノードとする)
    dist[s] = 0;
    que.push(s); // s を橙色頂点にする
    ans[s]=pq.top();
    pq.pop();
    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない
            
            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            ll cc=pq.top();
            ans[nv]=cc;
            cnt+=cc;
            pq.pop();
            que.push(nv);
        }
    }
    cout<<cnt<<'\n';
    rep(i,N) cout<<ans[i]<<' ';
}

Measured memory_bytes: 1152
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    a = LIST()
    min_cost = INF

    for i in range(3):
        for j in range(3):
            for k in range(3):
                if not i == j and not j == k and not k == i:
                    cost = abs(a[j]-a[i]) + abs(a[k]-a[j])
                    if cost < min_cost:
                        min_cost = cost

    print(min_cost)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector< pi > 
const int N=1005;
int dp[20*N],a[N],b[N];
int main()
{
  
  int h,n;
  cin>>h>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i]>>b[i];
    
  }
  for(int j=1;j<=h+10000;j++)
        dp[j]=mod;
  dp[0]=0;
  for(int i=1;i<=n;i++)
  {
    for(int j=a[i];j<=h+10000;j++)
    {
        dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
        //cout<<j<<" "<<dp[j]<<"\n";
    }
  }
  for(int i=h+1;i<=h+10000;i++)
    dp[h]=min(dp[h],dp[i]);
  if(dp[h]>=mod/2) dp[h]=-1;
  cout<<dp[h];


    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n, k;
string s;
int main()
{
    cin >> n >> k;
    cin >> s;
    vector<int> one, zero;
    int cnt = 1;
    for (int i = 1; i < n; i++)
    {
        if (s[i - 1] != s[i])
        {
            if (s[i - 1] == '0')
            {
                zero.push_back(cnt);
            }
            else
            {
                one.push_back(cnt);
            }
            cnt = 0;
        }
        cnt++;
    }
    if (s.back() == '0')
    {
        zero.push_back(cnt);
    }
    else
    {
        one.push_back(cnt);
    }
    zero.push_back(0);

    if (zero.size() <= k)
    {
        cout << n << endl;
        return 0;
    }
    int ans = 0;
    int fl = 0;
    if (s[0] == '0')
    {
        fl = 1;
    }
    for (int i = 0; i + k < one.size(); i++)
    {
        int tmp = 0;
        for (int j = i; j <= i + k; j++)
        {
            tmp += one[j];
            tmp += zero[j + fl];
        }
        tmp -= zero[i + k + fl];
        ans = max(tmp, ans);
    }
    if (fl)
    {
        int tmp = 0;
        for (int i = 0; i < k; i++)
        {
            tmp += zero[i];
            tmp += one[i];
        }
        ans = max(tmp, ans);
    }
    if (s.back() == '0')
    {
        int tmp = 0;
        for (int i = 0; i < k; i++)
        {
            tmp += zero[zero.size() - i - 2];
            tmp += one[one.size() - i - 1];
        }
        ans = max(tmp, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1020
n = int(input())
a = list(map(int, input().split()))

bits = [0] * 60
for d in a:
    for i in range(60):
        if d % 2 == 1:
            bits[i] += 1
        d >>= 1
        if d == 0:
            break

total = 0
mod = 10 ** 9 + 7
for i in range(60):
    total += (2 ** i) * (bits[i] * (n - bits[i]))
    total %= mod
print(total)


Measured memory_bytes: 122808
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
int const maxn=1e3+5;
char s[maxn];
int main()
{
	int n,a,b,res=0;
	bool flag=0;
	scanf("%d",&n);
	while(n--){
		scanf("%d%d",&a,&b);
		if(a==b) res++;
		else res=0;
		if(res>=3) flag=1;
	}
	if(flag) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 3684
def abc():
    n, m, x, y = map(int, input().rstrip().split())
    xx = [x]
    xx.extend(map(int, input().rstrip().split()))
    xx.sort()
    yy = [y]
    yy.extend(map(int, input().rstrip().split()))
    yy.sort()
    print('No War' if xx[-1] < yy[0] else 'War')


abc()


Measured memory_bytes: 3060
from collections import deque,defaultdict
import sys
rel=defaultdict(set)
n,m=map(int,input().split())
for s in sys.stdin:
  a,b=map(int,s.split())
  rel[int(a)].add(int(b))
  rel[int(b)].add(int(a))
cand=deque([1])
visited=set([1])
dlist=[0]*n
while len(visited)!=n:
  now=cand.popleft()
  for i in rel[now]:
    if i not in visited:
      cand.append(i)
      visited.add(i)
      dlist[i-1]=now
print('Yes')
print(*dlist[1:],sep='\n')

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

typedef long long ll;

ll N, P;
ll mx = 1;

int main() {
	scanf("%lld%lld", &N, &P);

	for (ll i = 2; i * i <= P; ++i) {
		int cnt = 0;
		while (!(P % i)) {
			cnt++;
			if (!(cnt % N)) mx *= i;
			P /= i;
		}
	}

	if (N == 1) mx *= P;

	printf("%lld\n", mx);
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int n;
  int p[100];
  int count=0;
  scanf("%d",&n);

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

  for(int i=0;i<n-1;i++){
    if(p[i]!=i+1){
      count++;
    }
  }
  if(count>2){
    puts("NO");
  }else{
    puts("YES");
  }

  return 0;
}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int q;
    cin >> q;
    set<int> se;
    while(q--) {
        int t, x;
        cin >> t >> x;
        if(t == 0) {
            se.insert(x);
            cout << se.size() << '\n';
        } else if(t == 1) {
            auto itr = se.find(x);
            cout << (itr != se.end()) << '\n';
        } else if(t == 2) {
            se.erase(x);
        } else {
            int r;
            cin >> r;
            auto itr = se.lower_bound(x);
            for(;*itr <= r and itr != se.end(); itr = next(itr)) {
                cout << *itr << '\n';
            }
        }
    }
}


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

using namespace std;
typedef long long ll;

#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 FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    vector<ll> start0(s.length()), start1(s.length()), src(s.length());
    ll n = s.length();
    REP(i, n)
    {

        if (i % 2)
        {
            start0[i] = 0;
            start1[i] = 1;
        }
        else
        {
            start0[i] = 1;
            start1[i] = 0;
        }
        if (s[i] == '0')
            src[i] = 0;
        else
            src[i] = 1;
    }
    ll res0 = 0, res1 = 0;
    REP(i, n)
    {
        if (start0[i] != src[i])
        {
            res0++;
        }
        if (start1[i] != src[i])
        {
            res1++;
        }
    }
    cout << (res0 < res1 ? res0 : res1) << endl;
    return 0;
}


Measured memory_bytes: 2816
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")
# define int long long

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e7;

int dp[N], h[N];

int32_t main() {
    speed;
    int n, k;
    cin >> n >> k;
    for ( int i = 1; i <= n; i++ ) {
        cin >> h[i];
        dp[i] = 1e12;
    }
    dp[1] = 0;
    for ( int i = 1; i <= n; i++ ) {
        for ( int j = 1; j <= k; j++ ) {
            dp[i + j] = min( dp[i + j], dp[i] + abs( h[i] - h[i + j] ) );
        }
    }
    cout << dp[n];
}


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

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
	//freopen("input.txt", "r", stdin);
	
	int n; cin>>n;
	int d; cin>>d;
	
	cout << (n+ 2 * d) / (2*d + 1);
	
	
	
}

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

#define mp make_pair
#define mx 105

int main(){
	//freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	
	int n, k;
	cin>>n>>k;

	int arr[n];
	int dp[n];
	
	for(int i=0;  i<n; i++){
		cin>>arr[i];
		if(i!=0)
			dp[i]=INT_MAX;
	}

	dp[0]=0;

	for(int i=0;i<n; i++){
		for(int j = 1; j<=k; j++){
			if(i+j<n){
				dp[i+j] = min(dp[i+j], dp[i] + abs(arr[i+j]-arr[i]));
			}
		}
	}

	cout<<dp[n-1]<<endl;
	return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
static const int MAX=100000;
int ans,cunt,A[MAX];
int main(){
    int N;
    cin>>N;
    for(int i=0;i<N;i++)
        cin>>A[i];
    sort(A,A+N);
    int ptr=0;
    while(ptr<N){
        cunt=0;
        int cc=A[ptr];
        while(ptr<N&&A[ptr]==cc){
            cunt++;
            ptr++;
        }
        ans+=cunt%2;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

#define LL long long
string s;
int W, H, x, y, r, a, b, c, num[5];

int main() {
	cin >> a >> b >> c;
	int ans = 0;
	for (int i = a; i <= b; i++) {
		if (c%i == 0)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
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;

char ba[1000][1000];
int dirdis[1000001][4];
int dirtable[1000001];

int dx[] = {0,1,0,-1};
int dy[] = {-1,0,1,0};

bool visited[1000][1000][4];

struct P {
  int y,x,d;
  int i;
};

const bool operator<(const P &a, const P &b) {
  return a.i > b.i;
}

int main() {
  int h,w,n;
  while(cin>>h>>w>>n,h||w||n) {
    string s;
    cin >> s;
    int sx,sy,gx,gy;
    int sd = 0;
    REP(i, h) {
      REP(j, w) {
        cin >> ba[i][j];
        if (ba[i][j] == 'S') {
          sy = i;
          sx = j;
        } else if (ba[i][j] == 'G') {
          gy = i;
          gx = j;
        }
      }
    }
    REP(i, n) {
      if (s[i] == 'L')
        dirtable[i+1] = (dirtable[i] + 3) % 4;
      else
        dirtable[i+1] = (dirtable[i] + 1) % 4;
    }
    int last[4];
    memset(last, -1, sizeof(last));
    for (int i=n; i>=0; --i) {
      REP(j, 4) {
        if (last[j] >= 0)
          dirdis[i][j] = last[j] - i;
        else
          dirdis[i][j] = -1;
      }
      last[dirtable[i]] = i;
    }
    priority_queue<P> Q;
    Q.push((P){sy,sx,sd,0});
    memset(visited,0,sizeof(visited));
    bool f = 0;
    while(!Q.empty()) {
      P now = Q.top(); Q.pop();
      int y=now.y, x=now.x, d=now.d;
      if (visited[y][x][d]) continue;
      visited[y][x][d] = 1;

      //printf("(%d,%d):%d:%d\n",x,y,d,now.i);
      
      if (y==gy&&x==gx) {
        f = 1;
        break;
      }
      
      REP(k,4) {
        if (d==k) continue;
        if (dirdis[now.i][k] !=-1) {
          Q.push((P){y,x,k,now.i+dirdis[now.i][k]});
        }
      }
      int yy = y+dy[d];
      int xx = x+dx[d];
      if (yy<0||yy>=h||xx<0||xx>=w||ba[yy][xx]=='#') continue;
      Q.push((P){yy,xx,d,now.i});
    }
    if (f)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <list>
#include <bitset>
using namespace std;

int main()
{
    int N;
    cin >> N;
    bool flag = false;
    for (int i = 0; i <= N; i += 4)
    {
        for (int j = 0; j <= N; j += 7)
        {
            if (i + j == N)
            {
                flag = true;
                break;
            }
        }
    }
    if (flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll a(N+1);
        rep(i, 1, N+1) cin >> a[i];
        vll ans(N+1);

        repreverse(i, N, 1) {
                ll sm = 0;
                rep(j, 1, inf) {
                        if (i * j > N) break;
                        if(ans[i * j] == 1) ++sm;
                }
                if (odd(sm) == odd(a[i])) continue;
                ans[i] = 1;
        }

        ll cnt = count(all(ans), 1);
        cout << cnt << endl;
        rep(i, 1, N+1) {
                if (ans[i] == 1) {
                        if (i != cnt) cout << i << ' ';
                        else cout << i << endl;
                }
        }
}

Measured memory_bytes: 6240
#include <stdio.h>
#include <string.h>

char s[200005], t[200005];
int g[2][30];
int len;

int main()
{
	int f = 1;

	scanf("%s", s);
	scanf("%s", t);
	
	len = strlen(s);
	for (int i = 0; i < len; i++) {
		if (g[0][s[i] - 'a'] == 0) {
			g[0][s[i] - 'a'] = t[i];
		} else if (g[0][s[i] - 'a'] != t[i]) {
			f = 0;
		}

		if (g[1][t[i] - 'a'] == 0) {
			g[1][t[i] - 'a'] = s[i];
		} else if (g[1][t[i] - 'a'] != s[i]) {
			f = 0;
		}
	}

	puts((f ? "Yes" : "No"));

	return 0;
}


Measured memory_bytes: 512
#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 = 1e9;
const double PI = acos(-1.0);

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

	int m, f, r;
	while(1) {
		cin >> m >> f >> r;
		if(m == -1 && f == -1 && r == -1) break;
		
		string ans;
		if(30 <= m + f) ans = "D";
		if(50 <= m + f || 50 <= r) ans = "C";
		if(65 <= m + f) ans = "B";
		if(80 <= m + f) ans = "A";
		if(m == -1 || f == -1 || m + f < 30) ans = "F";
		
		cout << ans << "\n";	
	}
	return 0;
}

Measured memory_bytes: 1180
nml = [int(s) for s in input().split()]
A = []
for n in range(nml[0]):
    a_n = [int(s) for s in input().split()]
    A.append(a_n)
B = []
for m in range(nml[1]):
    b_m = [int(s) for s in input().split()]
    B.append(b_m)

for i in range(nml[0]):
    c_i = []
    for j in range(nml[2]):
        c_ij = 0
        for k in range(nml[1]):
            c_ij += A[i][k] * B[k][j]
        c_i.append(str(c_ij))
    print(' '.join(c_i))
    


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

int main(){
    long long h, w;
    cin >> h >> w;
    char c[h][w];
    char c2[2*h][w];

    for(long long y = 0; y < h; y++){
        for(long long x = 0; x < w; x++){
            cin >> c[y][x];
        }
    }

    for(long long y = 0; y < 2*h; y++){
        for(long long x = 0; x < w; x++){
            c2[y][x] = c[y/2][x];
        }
    }


    for(long long y = 0; y < 2*h; y++){
        for(long long x = 0; x < w; x++){
            printf("%c", c2[y][x]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
using namespace std;
long long f[100];
int main()
{
	f[0]=2;
	int n;
	cin>>n;
	for(int i=0;i<=n;i++)
		f[i]=f[i-1]*2+2;
	cout<<f[n]<<endl;
	return 0;
}

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

#define mp make_pair
#define pb push_back

typedef pair<int, int> ii;
typedef long long ll;
typedef pair<ll, ll> l4;

const int maxn = 2e5+1;
int a[maxn], n;

int main()
{
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    {
      int x;
      scanf("%d", &x);
      a[x] = a[x-1] + 1;
    }
  printf("%d\n", n-*max_element(a+1, a+1+n));
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1e9+7;
const int INF=1e9;
const ll LINF=(ll)1e18;

int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    ll gr=0,le=0;
    int ans=0;
    vector<int> v;
    for(int i=0;i<n;i++){
        if(a[i]>b[i]){
            gr+=a[i]-b[i];
            v.push_back(b[i]-a[i]);
        }
        else if(a[i]<b[i]){
            le+=b[i]-a[i];
            ans++;
        }
    }
    if(ans==0){
        cout<<ans<<endl;
        return 0;
    }
    if(le>gr){
        cout<<-1<<endl;
        return 0;
    }
    sort(v.begin(),v.end());
    for(int p:v){
        le+=p;
        ans++;
        if(le<=0){
            cout<<ans<<endl;
            return 0;
        }
    }
}


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

using namespace std;

int main() {
    int a,b;

    cin >> a >> b;

    int sum = a + b;
    int diff = a - b;
    int mul = a * b;


    if(diff < sum && mul < sum ) {
        cout << sum << endl;
    } else if (diff < mul) {
        cout << mul << endl;
    } else {
        cout << diff << endl;
    }
}

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

using namespace std;

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

    int ans = 0;
    int x;
    for(int i=0; i<N; i++){
        cin >> x;
        ans += 2*min(K-x, x);
    }

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

Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t=1;
	//cin >> t;
	while(t--){
      	double a=0,b=0,v=0,w=0,time=0,dist=0,rv=0;
     	//int i=0;
      	cin >> a >> v >> b >> w >> time;
      	dist = abs(b-a);
      	rv = v-w;
      	
      	if(rv<=0||((dist/rv)>time&&(dist/rv)>0)){cout << "NO"<<endl;}
      	else cout << "YES"<<endl;
	}
}

Measured memory_bytes: 3724
#include<stdio.h>
int main(void) {
	int N, A, B, C, D;
	scanf("%d", &N);
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	scanf("%d", &D);

	int Acnt=0;
	int Ccnt=0;
	/*
	Acnt = (int(N / A) + 1)*B;
	Ccnt = (int(N / C) + 1)*D;
	*/
	int sub = N;
	while(1) {
		Acnt += B;
		if (sub - A <= 0) {
			break;
		}else {
			sub -= A;
		}
	}

	sub = N;
	while (1) {
		Ccnt += D;
		if (sub - C <= 0) {
			break;
		}
		else {
			sub -= C;
		}
	}

	int ans;
	if (Acnt < Ccnt) {
		ans = Acnt;
	}else {
		ans = Ccnt;
	}
	/*
	printf("%d\n", Acnt);
	printf("%d\n", Ccnt);
	*/
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2104
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

const LL mod = 1000000007;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>C(N);
	rep(i, N) in >> C[i];

	std::vector<LL>A;
	rep(i, N)
	{
		for (int j = i; j < N; ++j)
		{
			if (C[i] != C[j])
			{
				A.push_back(C[i]);
				i = j - 1;
				break;
			}
			if (j == N - 1)
			{
				A.push_back(C[i]);
				i = j;
				break;
			}
		}
	}
	N = A.size();

	std::vector<LL>dp(N), memo(212345);
	dp[0] = 1; memo[A[0]] = 1;
	for (LL i = 1; i < N; ++i)
	{
		dp[i] = (dp[i - 1] + memo[A[i]]) % mod;
		(memo[A[i]] += dp[i - 1]) %= mod;
	}
	out << dp[N - 1] << std::endl;
}


Measured memory_bytes: 6768
#include<iostream>
using namespace std;
int main()
{
	int a;
	int b;
	int c;
	cin >> a;
	cin >> b;
	cin >> c;

	if (a < b && b < c)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	


	
	return 0;
}


/*if (a > b)
{
	cout << "a > b" << endl;
}
if (a < b)
{
	cout << "a < b" << endl;
}
if (a == b)
{
	cout << "a == b" << endl;
}*/

Measured memory_bytes: 3112
/**
*    author:  souzai32
*    created: 23.08.2020 15:20:41
**/

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

bool Factorial(ll x, vector<ll>&f){
    f[0]=1;
    for(int i=1; i<=x; i++){
        f[i]=(f[i-1]*i)%mod;
    }
    return true;
}

int main() {

    int x,y,n;
    cin >> x >> y;
    if(x>y) swap(x,y);

    // vector<ll> f(x+1);
    // Factorial(x,f);

    // for(int i=0; i<=x; i++){
    //     cout << f[i] << endl;       
    // }

    // for(int i=0; i<=n; i++) cout << f[i] << endl;

    ll ans=0;
    if((x+y)%3==0){
        if(2*x>=y && x<=2*y){
            n=(x+y)/3;
            vector<ll> f(n+1);
            Factorial(n,f);
            ans=f[n];
            ll bit=mod-2;
            ll k=f[x-n];
            while(bit>0){
                if((bit&1)==1) ans=(ans*k)%mod;
                k=(k*k)%mod;
                bit>>=1;
            }
            bit=mod-2;
            k=f[2*n-x];
            while(bit>0){
                if((bit&1)==1) ans=(ans*k)%mod;
                k=(k*k)%mod;
                bit>>=1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8516
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=200010;
char s[N];
int ans,lst1,lst2,now1,now2;
int main(){
	scanf("%s",s+1);
	for(int i=1;s[i];i++){
		now1=(now1*181ll+s[i]-'a'+1)%1000000007;
		now2=(now2*233ll+s[i]-'a'+1)%998244353;
		if(now1!=lst1&&now2!=lst2){
			lst1=now1;
			lst2=now2;
			ans++;
			now1=0;
			now2=0;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long R, long long G, long long B, long long N){
    ll cnt = 0;
    for(ll r=0; r*R<= N; r++){
        for(ll g=0; (g*G+r*R)<= N; g++){
            ll tmp = N - r*R - g*G;
            if(tmp % B == 0)
                cnt ++;
        }
    }

    cout << cnt << endl;
}

int main(){
    long long R;
    scanf("%lld",&R);
    long long G;
    scanf("%lld",&G);
    long long B;
    scanf("%lld",&B);
    long long N;
    scanf("%lld",&N);
    solve(R, G, B, N);
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

d = defaultdict(lambda : 0)

n = int(input())
for _ in range(n):
    item = input()
    d[item] += 1

items = sorted(d.items(), key=lambda x: (x[1], x[0]), reverse=True)
c = items[0][1]
l = []
for k, v in items:
    if v < c:
        break
    l.append(k)
if len(l) == 1:
    print(l[0])
else:
    print('\n'.join(l[::-1]))


Measured memory_bytes: 62940
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  while (true) {
    int f = 0;
    for (int i = 2; i <= floor(sqrt(N)); i++) {
      if (N % i == 0) {
        f = 1;
        break;
      }
    }
    if (f == 0) {
      cout << N << endl;
      break;
    }
    N++;
  }
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int cnt[100];

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}
	for (int i = 1; i <= n; i++)cout << cnt[i] << endl;
	return 0;
}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    vector<ll> c(n);
    rep(i,n) c[i]=i+1;
    
    map<vector<ll>,ll> mp;
    do{
        mp[c]=mp.size();
    }while(next_permutation(c.begin(),c.end()));
    
    ll ans = abs(mp[a]-mp[b]);
    
    cout << ans << endl;
    
    return 0;
}








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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<int, int> ii;

const int N = 2e5 + 5;

string s;

int n, m, cnt1[N], cnt2[N];

bool used[N];

vector<int> graph[N];

map<ii, int> mymap;

queue<int> q;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> m;
    cin >> s;
    s = "+" + s;
    while(m--) {
        int u, v;
        cin >> u >> v;
        mymap[{u, v}] = mymap[{v, u}] = 1;
        graph[u].pb(v);
        graph[v].pb(u);
    }
    for(int i = 1; i <= n; i++) {
        int ok1 = 0, ok2 = 0;
        for(int j = 0; j < graph[i].size(); j++) {
            int u = graph[i][j];
            if(s[u] == 'A')
                cnt1[i]++;
            else
                cnt2[i]++;
        }
        if(cnt1[i] == 0 || cnt2[i] == 0)
            q.push(i), used[i] = 1;
    }
    while(!q.empty()) {
        int u = q.front();
        q.pop();
        for(int i = 0; i < graph[u].size(); i++) {
            int v = graph[u][i];
            if(!used[v]) {
                if(s[u] == 'A')
                    cnt1[v]--;
                else
                    cnt2[v]--;
                if(cnt1[v] == 0 || cnt2[v] == 0) {
                    q.push(v);
                    used[v] = 1;
                }
            }
        }
    }
    for(int i = 1; i <= n; i++) {
        if(!used[i]){
            cout << "Yes\n";
            exit(0);
        }
    }
    cout << "No\n";
}


Measured memory_bytes: 36264
#include <iostream>
using namespace std;
int main() {
    int mid, final, makeup;
    char grade;
    while(1) {
        cin >> mid >> final >> makeup;
        if (mid == -1 && final == -1 && makeup == -1) {
            break;
        } if (mid == -1 || final == -1) {
            grade = 'F';
        }else if (mid + final >= 80) {
            grade = 'A';
        }else if (mid + final >= 65) {
            grade = 'B';
        }else if (mid + final >= 50) {
            grade = 'C';
        }else if (mid + final >= 30) {
            if (makeup >= 50) {
                grade = 'C';
            }else {
                grade = 'D';
            }
        }else {
            grade = 'F';
        }
        cout << grade << endl;
    }
    return 0;
}


Measured memory_bytes: 3064
//

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

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

  return 0;
}


Measured memory_bytes: 256