akhauriyash/Code-Regression huggingface dataset:
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define db long double
# define IOS ios_base :: sync_with_stdio(0)
# define halt(...) {fo << (__VA_ARGS__) << '\n';exit(0);}
# define pp(n) cerr << #n << " = " << n << '\n'
# define ppp(v) for (auto it : v) cerr << it << ' ';cerr << '\n'
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    vector < string > s;
    int n,l;
    int *ok = new int[10];
    fi>>n>>l;
    for (int i = 0;i <= 9;++i) ok[i] = 0;
    while (l --)
    {
        int x;
        fi>>x;
        ok[x] = 1;
    }
    auto norm = [&](int x)
    {
        if (!x) return ok[x];
        while (x)
        {
            if (ok[x % 10]) return 1;
            x /= 10;
        }
        return 0;
    };
    while (norm(n)) ++n;
    fo << n << '\n';
    return 0;
}

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


int main ()
{

int arr[3];

cin >> arr[0] >> arr[1] >> arr[2];

sort(arr, arr+3);

cout << (arr[2]*10)+(arr[1])+arr[0] << endl ;

 	return 0;
}












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

int main() {
  int A, B, ans;
  cin >> A >> B ;
  if ((B-1)%(A-1) == 0)
  {
    ans = (B-1)/(A-1);
  }else
  {
    ans = (B-1)/(A-1)+1;
  }
  
  cout << ans <<endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  int ans = 0;
  while(n>0){
    ans += n % 10;
    n /= 10;
  }
  if(ans == 1){
    ans = 10;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
// cout << "Case #" << test << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int s, w;
    cin >> s >> w;
    if(w >= s) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}


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



int main() {
    int H,W;
    while (true) {
        cin >> H >> W;
        if (H==0 && W==0) break;
        for (int i=0; i<H; ++i) {
            for (int j=0; j<W; ++j) {
                if (i==0 || i%2==0) {
                    if (j==0 || j%2==0) {
                        cout << '#';
                    }else{
                        cout << '.';
                    }
                }else{
                    if (j==0 || j%2==0) {
                        cout << '.';
                    }else{
                        cout << '#';
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
def f()
  n = STDIN.readline.chomp.to_i
  ot = 0
  ox = 0
  oy = 0

  1.upto(n) do |i|
    t, x, y = STDIN.readline.chomp.split(' ').map(&:to_i)
    dt = t - ot
    d = (x - ox).abs + (y - oy).abs
    if (d > dt) || (((dt - d) % 2) > 0)
      return false
    end

    ot = t
    ox = x
    oy = y
  end
  true
end

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


Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;

#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) break;
    string c;
    cin >> c;
    int r = 0;
    vector<int> p(n);
    for (int i = 0; i < 100; i++) {
      switch(c[i]) {
      case 'M': p[i%n]++; break;
      case 'S': r += p[i%n] + 1; p[i%n] = 0; break;
      case 'L': p[i%n] += r + 1; r = 0; break;
      }
    }
    sort(p.begin(), p.end());
    for (int i = 0; i < n; i++)
      cout << p[i] << " ";
    cout << r << endl;
  }
}

Measured memory_bytes: 1220
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

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


Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  s <- T.getLine :: IO T.Text
  putStrLn $ if s == T.pack "AAA" || s == T.pack "BBB" then "No" else "Yes"

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define endl '\n'
#define pri 1000000007
#define all(x) x.begin(),x.end()
#define mnx 1000001
#define pr pair<ll,ll>
using namespace std;

void masterstroke(){
ll n,l;cin>>n>>l;
ll s=0;
for(ll i=0;i<n;i++)
{s+=(l+i);}

if(l<=0&&(l+n-1)>=0){

}
else if(l>0){
	s-=(l);
}
else{
	s-=(n+l-1);
}
cout<<s<<endl;

}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)masterstroke();
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    int x;
    cin >> x;
    if(x == 5){
        cout << "YES" << endl;
    }else if(x == 3){
        cout << "YES" << endl;
    }else if(x == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define DEC(i, a, b) for (int i = (a); i > (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
typedef long long ll;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const ll LINF = (int)1e18;
const double EPS = 1e-9;

signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int A,B,C;
  cin>>A>>B>>C;
  cout << min(B/A,C) << endl;
  return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
  typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second
#define all v.begin(),v.end()
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef unsigned long long ulll;
 
using namespace std ;
int main () {

  int a,b;
  cin>>a>>b;
  
  cout<<ceil((a+b)/2.0);
   
  return 0;
}

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

MOD = pow(10, 9) + 7

two_inv = pow(2, -1, MOD)

sq = []

for x in a:
    sq.append(x ** 2 % MOD)

s = sum(a) % MOD
s_sq = sum(sq) % MOD

print((pow(s, 2, MOD) - s_sq) * two_inv % MOD)

Measured memory_bytes: 31408
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int diff = b - a;

		int height = 0;
		for (int i = 1; i <  diff; i++) {
			height = height + i;
		}
		System.out.println(height - a);

	}
}


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

int main()
{   int i,n,a[2000];
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {  int x;
     scanf("%d",&x);
     if(x%2==0)
     {   if(x%3==0||x%5==0)
          continue;
          else break;
     }
   }
   if(i==n)printf("APPROVED");
   else printf("DENIED");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=305;
#define fi first
#define se second
typedef pair<int,int>P;
priority_queue<P>que;
int n,m,b[N],vi[N],cnt[N],a[N][N];
bool check(int mid){
	while(!que.empty())	que.pop();
	for(int i=1;i<=m;i++)	b[i]=0;
	for(int i=1;i<=n;i++)	++b[a[i][cnt[i]=1]];
	for(int i=1;i<=m;i++)	vi[i]=0,que.push(P(b[i],i));
	while(!que.empty()){
		P x=que.top();	que.pop();
		if(vi[x.se])	continue;
		if(x.fi<=mid)	return true;

		vi[x.se]=1;
		for(int i=1;i<=n;i++){
			if(a[i][cnt[i]]!=x.se)	continue;
			while(vi[a[i][cnt[i]]]&&cnt[i]<=m)	++cnt[i];
			if(cnt[i]>m)	return false;
			que.push(P(++b[a[i][cnt[i]]],a[i][cnt[i]]));
		}
	}
	return false;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&a[i][j]);
	int l=1,r=n;
	while(l<r){
		int mid=(l+r)>>1;
		if(check(mid))	r=mid;
		else	l=++mid;
	}
	printf("%d\n",l);
	return 0;
}


Measured memory_bytes: 1784
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	char s[4];
	char abc[] = "ABC";
	char arc[] = "ARC";

	scanf("%s", &s);

	if (strcmp(s, abc) == 0)
	{
		printf("%s\n",arc);
	}
	else
	{
		printf("%s\n", abc);
	}

	return 0;
}

Measured memory_bytes: 1624
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }

    int mx = 0;
    for (auto x : mp) mx = max(mx, x.se);

    vstr S;
    for (auto x : mp) if (x.se == mx) cout << x.fi << endl;

    return 0;
}

Measured memory_bytes: 27136
using System;

namespace abc169_c
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] AB = Console.ReadLine().Split(" ");
            long A = long.Parse(AB[0]);
            double B = double.Parse(AB[1]);
            long B100 = (long)Math.Round(B *100);
            long sum = A * B100;
            sum = sum / 100;
            Console.WriteLine(sum);
        }
    }
}


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

int main() {
	int n;
	scanf("%d", &n);
	int a[n], b[n];
	for (int i=0; i<n; i++) scanf("%d", &a[i]);
	for (int i=0; i<n; i++) scanf("%d", &b[i]);
	long long use=0;
	for (int i=0; i<n; i++) {
		if (b[i]>=a[i]) use+=(b[i]-a[i])/2;
		else use-=(a[i]-b[i]);
	}
	printf("%s\n", use>=0?"Yes":"No");
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI c(n);
	rep(i, n) cin >>c[i];
	c.erase(unique(all(c)), c.end());
	//for(auto x : c) printf("%d ",x); puts("");
	n=sz(c);
	if(n <=1){puts("1"); return 0;}
	ll ans =0;
	vector<ll> dp(n+5), sm(200100);
	dp[0] = 1;
	rep(i, n){
		(dp[i+1] = dp[i] + sm[c[i]]) %=mod;
		
		(sm[c[i]] += dp[i]) %=mod;
	}
	cout << dp[n]%mod <<"\n";
	return 0;
}



Measured memory_bytes: 4096
# include<iostream>
using namespace std;
int cal(int a, int b)
{
    if(a > b)
        return a-b;
    else
        return b-a;
}
int main(void)
{
    std::ios::sync_with_stdio(false);
    int n;
    while(cin >> n && n!=0)
    {
        int a[100005];
        int i;
        for(i = 1; i <= n; ++i)
            cin >> a[i];

        int fro[100005];
        int bac[100005];
        fro[0] = 0;
        for(i = 1; i <= n; ++i)
        {
            fro[i] = fro[i-1] +  cal(a[i], a[i-1]);
        }
        fro[n+1] = fro[n] +  cal(0, a[n]);

        bac[n+1] = 0;
        for(i = n; i >= 0; --i)
        {
            bac[i] = bac[i+1] +  cal(a[i], a[i+1]);
        }
        bac[0] = fro[n+1];

        for(i = 1; i <= n; ++i)
        {
            int x = cal(a[i+1],a[i-1]);

            cout << fro[i-1] + bac[i+1] + x << endl;
        }
    }
    return 0;
}


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

int main()
{
    string *name;
    int *work;
    int i, n, q, rest, st_rest, yet, total;
    scanf("%d %d", &n, &q);
    name = new string [n * 2 + 1];
    work = new int [n * 2 + 1];
    if(name == NULL || work == NULL) return 0;
    for(i = 0; i < n; i++){ cin >> name[i]; scanf("%d", &work[i]); }
    rest = n; yet = n, total = 0;

    while(rest){
        st_rest = rest;
        for(i = 0; i < st_rest; i++){
            if(work[i] > q){
                name[yet] = name[i];
                work[yet] = work[i] - q;
                yet++; total += q;
            }else{
                total += work[i];
                cout << name[i]; printf(" %d\n", total);
                rest--;
            }
        }
        if(rest){
            for(i = 0; i < rest; i++){
                name[i] = name[i + n];
                work[i] = work[i + n];
            }
        }
        yet = n;
    };
    delete [] name; delete [] work;
    return 0;
}

Measured memory_bytes: 4476
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	string S;
	cin >> S;
	sort(all(S));
	if (S == "abc")
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int rr,cc,kk;
    cin>>rr>>cc>>kk;
    vl r(kk),c(kk),v(kk);
    vector<vector<vector<LL>>> dp(rr+1,vector<vector<LL>>(cc+1,vector<LL>(5,0)));
    vll mp(rr+1,vl(cc+1,0));
    LL ans=0;
    FOR(i,0,kk){
        cin>>r[i]>>c[i]>>v[i];
        mp[r[i]-1][c[i]-1]=v[i];
        if(r[i]==1&&c[i]==1){
            dp[0][0][1]=v[i];
        }
    }
    FOR(i,0,rr){
        FOR(j,0,cc){
            FOR(k,0,4){
                ans=max(ans,dp[i][j][k]);
                dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
                if(mp[i+1][j]){
                    dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][k]+mp[i+1][j]);
                }
                dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
                if(mp[i][j+1]){
                    dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+mp[i][j+1]);
                }
            }
        }
    }
    cout<<ans<<endl;
    

}


Measured memory_bytes: 711648
#include <bits/stdc++.h>
using namespace std; void solve(); int main(){cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(10); solve();}
using ll=int_fast64_t; using ld=long double; using pll=pair<ll,ll>; using pld=pair<ld,ld>;
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
template<class T> void vecout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
	ll n; cin>>n;
	ld ans=0,a;
	rep(i,n){
		cin>>a;
		ans+=1/a;
	}
	cout<<1/ans<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
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;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////

int main() {
   ll ans = 0;
   int N;
   cin >> N;
   rep(i,N)
   {
	   ll a; cin >> a;
	   ll p = a;
	   rep(j,p)
	   {
		   if(a % 2 == 0){ans ++; a = a/2;}
		   else break;
	   }
   }

   cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
typedef long long ll;
int a,b,c;
int p1[N][6][6][6],p2[N][6][6][6],p3[N][6][6][6];
char opt[N][6][6][6];
bool dp[N][6][6][6];
void updatedp(int x,int a,int b,int c,int aa,int bb,int cc,char optt)
{
    dp[x][a][b][c]=true;
    p1[x][a][b][c]=aa;
    p2[x][a][b][c]=bb;
    p3[x][a][b][c]=cc;
    opt[x][a][b][c]=optt;
}
void AB(int x)
{
    for(int a=0;a<6;a++)
        for(int b=0;b<6;b++)
        for(int c=0;c<6;c++)
        if(dp[x-1][a][b][c])
    {
        if(a-1>=0)
            updatedp(x,a-1,min(b+1,5),c,a,b,c,'B');
        if(b-1>=0)
            updatedp(x,min(a+1,5),b-1,c,a,b,c,'A');
    }
}
void AC(int x)
{
    for(int a=0;a<6;a++)
        for(int b=0;b<6;b++)
        for(int c=0;c<6;c++)
        if(dp[x-1][a][b][c])
    {
        if(a-1>=0)
            updatedp(x,a-1,b,min(c+1,5),a,b,c,'C');
        if(c-1>=0)
            updatedp(x,min(a+1,5),b,c-1,a,b,c,'A');
    }
}
void BC(int x)
{
    for(int a=0;a<6;a++)
        for(int b=0;b<6;b++)
        for(int c=0;c<6;c++)
        if(dp[x-1][a][b][c])
    {
        if(b-1>=0)
            updatedp(x,a,b-1,min(c+1,5),a,b,c,'C');
        if(c-1>=0)
            updatedp(x,a,min(b+1,5),c-1,a,b,c,'B');
    }
}
void getans(int x,int a,int b,int c)
{
    if(x==0) return;
    getans(x-1,p1[x][a][b][c],p2[x][a][b][c],p3[x][a][b][c]);
    printf("%c\n",opt[x][a][b][c]);
}
int main()
{
    int n;scanf("%d",&n);
    scanf("%d%d%d",&a,&b,&c);
    a=min(a,5);b=min(b,5);c=min(c,5);
    dp[0][a][b][c]=true;
    for(int i=1;i<=n;i++)
    {
        string opt;
        cin>>opt;
        if(opt=="AB") AB(i);
        else if(opt=="AC") AC(i);
        else BC(i);
    }
    for(int i=0;i<6;i++)
        for(int j=0;j<6;j++)
        for(int k=0;k<6;k++)
        if(dp[n][i][j][k])
    {
        printf("Yes\n");
        getans(n,i,j,k);return 0;
    }
    printf("No\n");
}


Measured memory_bytes: 303800
//agrawal117
//chahatagrawal117
#include<bits/stdc++.h>
#define endl '\n'
#define mod 1000000007
typedef long long int ll;
using namespace std;
#define MAX 100005
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n; cin>>n;
    while(n>0)
    {
        ll x=n%10;
        if(x==7) {cout<<"Yes"<<endl; return 0; }
        n/=10;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3648
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
   char s[200];
    int sum=0;
    cin>>s;
    int l=strlen(s);
    for(int i=0; i<=l/2-1; i++)
    {
        if(s[i]!=s[l-1-i])
            sum++;
    }
    cout<<sum<<endl;
}



Measured memory_bytes: 256
// O(nk)
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#define l first
#define r second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int N=200010;
const ll mod=998244353;
int n,k;
ll f[N],s[N];
pii a[N];
int main()
{
    IO;
    int minpos=1e9;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
    	cin>>a[i].l>>a[i].r;
    	minpos=min(minpos,a[i].l);
	}
    f[1]=1;
    s[1]=1;
    for(int i=1+minpos;i<=n;i++){
        for(int j=1;j<=k;j++)
            f[i]=(f[i]+s[max(0,i-a[j].l)]-s[max(0,i-a[j].r-1)])%mod;;
        s[i]=(s[i-1]+f[i])%mod;
    }    
    cout<<(f[n]+mod)%mod<<'\n';
    return 0;
}



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

int main()
{
	map<string, int > m;
	int n ;
	cin >> n;
	while (n--)
	{
		string s;
		cin >> s;
		m[s]++;

	}
	map<string, int > :: iterator it;
	int count = 0;
	for (it = m.begin(); it != m.end(); ++it)
	{
		count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 19256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i, j, n) for(int i = j; i < (int)n; ++i)

struct UnionFind {
  vector<int> par, weight;
  UnionFind(int n) : par(n,-1), weight(n) {}
  void unite(int x, int y, int w = 0) {
    w += get_weight(x); w -= get_weight(y);
    x = find(x); y = find(y);
    if (x == y) return;
    if (par[x] > par[y]) swap(x, y), w = -w;
    par[x] += par[y];
    par[y] = x;
    weight[y] = w;
    return;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int find(int x) {
    if(par[x] < 0) return x;
    int r = find(par[x]);
    weight[x] += get_weight(par[x]);
    return par[x] = r;
  }
  int sizeOf(int x) { return -par[find(x)]; }
  int get_weight(int x) { find(x); return weight[x]; }
  int diff(int x, int y) { return get_weight(y) - get_weight(x); }
};


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

    int n, m; cin >> n >> m;
    ll l, r, d;
    UnionFind uf(n);
    rep(i, 0, m) {
        cin >> l >> r >> d;
        --l, --r;
        if (uf.same(l, r)) {
            if (uf.diff(l, r) != d) {
                cout << "No" << endl;
                return 0;
            }
        } else uf.unite(l, r, d);
    }

    cout << "Yes" << endl;
    return 0;
}

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

int main() {
  int N, A, B, C, D;
  cin >> N;
  A = N / 1000;
  B = ( N - A * 1000 ) / 100 ;
  C = ( N - A * 1000 - B * 100 ) / 10 ;
  D = ( N - A * 1000 - B * 100 - C * 10) ;
  
  if ( B == C ) {
    if ( A == B || C == D ) {
    cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
from math import floor

K = int(input())
A, B = list(map(int, input().split()))
# print(K, A, B)

# 解法1
# answer = 'NG'
# for number in range(A, B + 1):
#     if number % K ==0:
#         answer = 'OK'
#         break

# 解法2
greatest_multiple = floor(B / K) * K
answer = 'OK' if A <= greatest_multiple else 'NG'

print(answer)


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}

int main() {
  ll N, K; cin >> N >> K;
  vector<ll> a(N), b(N);
  REP(i, N) cin >> a[i] >> b[i];

  map<ll, ll> m;
  for(int i = 0; i < N; ++i) {
    m[a.at(i)] += b.at(i);
  }

  ll cnt = 0;
  ll ans = 0;
  for(auto x : m) {
    cnt += x.second;
    if(cnt >= K) {
      ans = x.first;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    char s;
    cin >> s;
    
    if (s >= 'a' && s <= 'z'){
        cout << "a" << endl;
    }
    else {
        cout << "A" << endl;
    }
}


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

int main(void){
    int n;
    cin >> n;
    
    vector<int> a(n+1), b(n);
    rep(i, n+1){
        cin >> a.at(i);
    }
    rep(i, n){
        cin  >> b.at(i);
    }
    
    long long count = 0;
    rep(i, n){
        if(b.at(i) > a.at(i)){
            count += a.at(i);
            b.at(i) -= a.at(i);
            if(b.at(i) > a.at(i+1)){
                count += a.at(i+1);
                a.at(i+1) = 0;
            } else {
                a.at(i+1) -= b.at(i);
                count += b.at(i);
            }
        } else {
            count += b.at(i);
        }
    }
    
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;
#define matrix(T) vector<vector<T>>
#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define pqueue priority_queue
#define pushb push_back
#define fi first
#define se second
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define ABS(x) ( (x)>0 ? (x) : -(x) )
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define init(v) for(auto &a_: v) cin>>a_
#define out(n) cout<<n<<endl

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

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

ll nPr(ll n, ll r) {
	if(n<r) return 0;

	ll result=1LL;
	for(ll i=0; i<r; i++) result*=n-i;
	return result;
}

ll nPrP(ll n, ll r, ll p) { // mod pにおけるnPr
	if(n<r) return 0;

	ll result=1LL;
	for(int i=0; i<r; i++) {
		result*=n-i;
		result%=p;
	}
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll wari=1LL;
	while(n/wari) {
		digit++;
		wari*=10;
	}
	return digit;
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}


int N;

void input() {
	cin>>N;
}

void dfs(string now, int mx) {
	if(now.length()==N) {
		cout<<now<<endl;
		return;
	}
	for(int i=0; i<mx; i++) {
		dfs(now+(char)('a'+i),mx);
	}
	dfs(now+(char)('a'+mx),mx+1);
}

void solve() {
	string s="";
	dfs(s,0);
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


Measured memory_bytes: 1536
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

double d;

int main(void)
{
	cin >> d;
	double ans = 0;
	for(int i = 0; i <= 10; i++){
		double x = d*d-i*i;
		if(x < 0) continue;
		ans = max(ans, i + sqrt(x));
	}
	ans = max(ans, d * sqrt(2));
	ans = max(ans, floor(d+1e-9)+1);
	printf("%.11f\n", ans);
	return 0;
}


Measured memory_bytes: 3292
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls int
#define give main()
const int mod = 1000000007;
#pragma endregion
const int N = 200005;

ll n, k, arr[N], ans;

pls give {
    AC;
    cin >> n >> k;
    for (int i=0; i<n; i++) cin >> arr[i];
    sort(arr, arr+n, greater<>());
    for (int i=k; i<n; i++) ans += arr[i];
    cout << ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    cin>>s;
    for(char a='a';a<='z';a++){
        if(s.find(a)==string::npos){
            cout<<a<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
// #define int ll
using PII = pair<int, int>;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
 
template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
 
template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) { 
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }
 
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<40;
const ll MOD = 1000000007;

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

  ll n;
  cin >> n;
  n = 2*n-1;
  vector<ll> a(n);
  REP(i, n) cin >> a[i];
  
  //         0
  //       1,0,0
  //     1,0,1,0,0
  //   1,0,1,0,1,0,0
  // 1,0,1,0,1,0,1,0,0

  auto check = [&](ll mid) -> bool {
    vector<ll> v(n);
    REP(i, n) v[i] = a[i] >= mid;

    ll prev = 0;
    FOR(i, 1, n) {
      if(v[i] == v[i-1]) {
        // cout << prev << " " << i << endl;
        if(prev < i-1) {
          // if(v[prev] == v[i-1]) {
          //   FOR(j, prev, i) v[j] = v[prev];
          // } else {
            ll x = ceil(prev+i-1, 2LL);
            FOR(j, prev, x) v[j] = v[prev];
            FOR(j, x, i) v[j] = v[i];
          // }
        }
        prev = i;
      }
    }
    if(prev < n-1) {
      // if(v[prev] == v[n-1]) {
      //   FOR(j, prev, n) v[j] = v[prev];
      // } else {
        ll x = ceil(prev+n-1, 2LL);
        FOR(j, prev, x) v[j] = v[prev];
        FOR(j, x, n) v[j] = v[n-1];
      // }
    }
    return v[n/2];
  };

  // cout << check(5) << endl;

  ll lb = 1, ub = n+1;
  while(ub-lb > 1) {
    ll mid = (lb+ub)/2;
    if(check(mid)) lb = mid;
    else ub = mid;
  }

  cout << lb << endl;

  return 0;
}


Measured memory_bytes: 3436
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,i,j,x,ans;
int main(){
	scanf("%lld%lld",&n,&m);
	if(!m){
		printf("%lld",n*n);
		return 0;
	}
	for(i=1;i<=n-m;i++){
		x=i+m;
		ans+=n/x*i;
		if(n%x>=m)ans+=n%x-m+1;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int,int,int> T;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define MP make_pair
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using vvec = vector<vector<int>>;
using vec = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    REP(i,n) cin >> h[i];
    sort(rall(h));
    rep(i,min(n,k)){
        h[i]=0;
    }
    int s=0;
    rep(i,n){
        s+=h[i];
    }
    cout<<s<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

r = []
n.times do |i|
  s = 0
  n.times do |j|
    s += if j < i
           a[j]
         elsif j > i
           b[j]
         else
           a[j] + b[j]
         end
  end
  r << s
end

p r.sort[-1]


Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0 ; i < n ; i++) a[i] = sc.nextInt();
		int ans = 0;
		int i = 0;
		while(i < n) {
			if(i == n - 1) {
				ans++;
				break;
			}
			if(a[i] < a[i + 1]) {
				i++;
				while(i + 1 < n) {
					if(a[i] > a[i + 1]) {
						ans++;
						i++;
						break;
					} else {
						i++;
					}
				}
			} else if(a[i] > a[i + 1]) {
				i++;
				while(i + 1 < n) {
					if(a[i] < a[i + 1]) {
						ans++;
						i++;
						break;
					} else {
						i++;
					}
				}
			} else {
				i++;
				continue;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 50452
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

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

typedef long long int ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<pii> vpii;
typedef vector<vint> det1;
typedef vector<vpii> det2;

const int MAXN = 100;
int P[MAXN];

int main()
{
    int N, A, B;
    cin >> N >> A >> B;

    rep(i, N) { cin >> P[i]; }

    int p[3] = { 0 };

    rep(i, N)
    {
        const int pi = (P[i] <= A ? 0 : (P[i] <= B ? 1 : 2));
        ++p[pi];
    }

    sort(p, p + 3);

    cout << p[0] << endl;

    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
t=""
k=""
ans=0
l=[]
for i in range(1,n):
    ans1=0
    t=sorted(set(s[:i]))
    k=sorted(set(s[i:]))
    for i in t:
        for j in k:
            if i==j:
                ans1+=1
    l.append(ans1)
print(max(l))

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  ll ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      ll mint = max(v[i] - v[j], v[j] - v[i]);
      ll maxt = v[i] + v[j];
      ll t = lower_bound(v.begin(), v.end(), maxt) - upper_bound(v.begin(), v.end(), mint);
      if (mint < v[i] && v[i] < maxt) t--;
      if (mint < v[j] && v[j] < maxt) t--;
      ans += t;
    }
  cout << ans / 6 << endl;
  return 0;
}


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

int imp = 0;
const int N = 1e5;
ll a[N];
vector<int> treeone[N];

bool calc(int i, ll s, ll mx) {
  ll tx;
  if(mx * 2 < s) {
    tx = s / 2;
  } else {
    tx = s - mx;
  }
  return s - a[i] <= tx;
}

ll dfs(int i, int p = -1) {
  if(imp) return -1;
  if(p != -1 && (int) treeone[i].size() == 1) return a[i];
  ll s = 0, mx = 0;

  for(int j : treeone[i]) if(p != j) {
    ll t = dfs(j, i);
    if(imp) return -1;
    mx = max(mx, t);
    s += t;
  }
  // t + (s - t) / 2 = A
  // 2 t + s - t = 2 A
  // t = 2 A - s
  ll t = 2 * a[i] - s;
  if(t < 0 || s - a[i] < 0) {
    imp = 1; return -1;
  }
  bool ok = calc(i, s, mx);
  if(!ok) {
    imp = 1; return -1;
  }
  return t;
}

int solve() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n; cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < n - 1; i++) {
    int x, y; cin >> x >> y; x--; y--;
    treeone[x].emplace_back(y);
    treeone[y].emplace_back(x);
  }
  if(n == 2) return a[0] == a[1];
  int x;
  for(int i = 0; i < n; i++) if((int) treeone[i].size() != 1) x = i;
  if(dfs(x) > 0) return 0;
  return !imp;
}

int main() {
  cout << (solve() ? "YES" : "NO") << endl;
}



Measured memory_bytes: 13696
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String[] line = in.nextLine().split(" ");
        final int r = Integer.parseInt(line[0]);
        final int c = Integer.parseInt(line[1]);
        final int K = Integer.parseInt(line[2]);
        final int[][] matrix = new int[r][c];
        for (int i = 0; i < K; i++) {
            line = in.nextLine().split(" ");
            final int row = Integer.parseInt(line[0]);
            final int col = Integer.parseInt(line[1]);
            final int v = Integer.parseInt(line[2]);
            matrix[row - 1][col - 1] = v;
        }
        final long[][][] dp = new long[r][c][4];
        dp[0][0][1] = matrix[0][0];
        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                for (int k = 0; k < 4; k++) {
                    if (i > 0) {
                        dp[i][j][k] = Math.max(dp[i][j][k], dp[i - 1][j][k]);
                        dp[i][j][1] = Math.max(dp[i][j][1], dp[i - 1][j][k] + matrix[i][j]);
                    }
                    if (j > 0) {
                        dp[i][j][k] = Math.max(dp[i][j][k], dp[i][j - 1][k]);
                        if (k > 0) {
                            dp[i][j][k] = Math.max(dp[i][j][k], dp[i][j - 1][k - 1] + matrix[i][j]);
                        }
                    }
                }
            }
        }
        long res = 0;
        for (long ans : dp[r - 1][c - 1]) {
            res = Math.max(res, ans);
        }
        System.out.println(res);
    }
}


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

using namespace std;

typedef long long ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    int ret = 0;
    ret += N * (N-1) / 2;
    ret += M * (M-1) / 2;

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
ca=dict(Counter(a))
ablans=set([k for k,v in ca.items() if v==1])
notans=set([k for k,v in ca.items() if v>1])
if len(a)==0:
  print(0)
  exit()
a.sort()
maxa=a[-1]
for ai in a:
  i=2
  while maxa>=i*ai:
    ablans.discard(i*ai)
    i+=1
print(len(ablans))


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

int main() {
  string S;
  cin >> S;
  int sz = S.size();
  vector<int> n(sz);
  for (int i = 0; i < sz; i++) {
    n[i] = S[i]-'0';
  }
  long long ans=0;
  for (int bit = 0; bit < (1 << (sz-1)); bit++) {
    vector<long long> f = {n[0]};
    long long fsz = 1, sum = 0;
    for (int i = 0; i < sz-1; i++) {
      if ((1<<i)&bit) {
        f[fsz-1] = f[fsz-1]*10 + n[i+1];
      }
      else {
        f.push_back(n[i+1]);
        fsz++;
      }
    }
    for (int i = 0; i < fsz; i++) {
      sum += f[i];
    }
    ans += sum; 
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int A,B,C,D,E,F;
	scanf("%d%d%d%d%d%d",&A,&B,&C,&D,&E,&F);
	int ansx=min(A,B)*100,ansy=0;
	for(int i=0;i*A*100<=F;i++)
		for(int j=0;j*B*100+i*A*100<=F;j++){
			int x=(i*A+j*B)*100;
			for(int a=0;x+a*C<=F && a*C<=x/100*E;a++)
				for(int b=0;x+a*C+b*D<=F && a*C+b*D<=x/100*E;b++){
					int y=a*C+b*D;
					if(y*ansx>x*ansy)
						ansx=x,ansy=y;
				}
		}
	printf("%d %d\n",ansx+ansy,ansy);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const long int p=1e9+7;

using namespace std;

void fun()
{
    long long int n,k;
    cin>>n>>k;

    long long res=0;
   for (int x = k; x <= n + 1; x++) {
        long minsum = (long)x * (x - 1) / 2; //0 + 1 + .. + x - 1
        long maxsum = (long)n * x - minsum;  //n + (n - 1) + ... + (n - (x - 1));
        res += (maxsum - minsum + 1);
        res %= 1000000007;
    }
    cout << res << "\n";

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

    fun();
    return 0;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var array = Console.ReadLine().Split(' ');

        var days = int.Parse(input[0]);
        var nums = int.Parse(input[1]);

        

        foreach(var n in array)
        {
            days = days - int.Parse(n);
        }

        if(days < 0)
        {
            Console.WriteLine(-1);
        }
        else
        {
            Console.WriteLine(days);
        }
        Console.ReadKey();

    }
}


Measured memory_bytes: 19248