akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
  int S;
  cin >> S;
  
  vector<mint> dp(S + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < S; i++) {
    for (int j = 3; j <= S; j++) {
      if (i + j <= S) dp[i + j] += dp[i];
    }
  }
  cout << dp[S] << endl;
  return 0; 
}


Measured memory_bytes: 3608
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;
int main(){
	double point, a, n, s[1000], m;//a標準偏差 n学生の数
	while (1){
		m = 0;
		point = 0;
		cin >> n;
		if (n == 0)break;
		a = 0;

		for (int i = 0; i < n; i++){
			cin >> s[i];
			point += s[i];
		}

		m = point / n;

		for (int i = 0; i < n; i++){
			a += pow(s[i] - m, 2);
		}
		a = sqrt(a / n);
		printf("%f\n", a);
	}

	return 0;
}


Measured memory_bytes: 3196
#include<iostream>
#include<cctype>
#include<string>
using namespace std;

 int main(){
   string S1, S2, S3;
   cin >> S1 >> S2 >> S3;

   S1 = toupper(S1[0]);
   S2 = toupper(S2[0]);
   S3 = toupper(S3[0]);
  
   cout << "\n";
   cout << S1 << S2 << S3 << endl;

 return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int chkcount(char a,char b,char c){
    int count=0;

    if(a==b&&b==c){
        return 0;
    }
    if(a==b||b==c||a==c){
        return 1;
    }
    return 2;
}


int main(void){
    int N;
    scanf("%d",&N);
    char A[N];
    char B[N];
    char C[N];
    scanf("%s",A);
    scanf("%s",B);
    scanf("%s",C);

    int count = 0;
    for(int i=0;i<N;i++){
        count += chkcount(A[i],B[i],C[i]);
    }

    printf("%d",count);

    return 0;
}

Measured memory_bytes: 128
using System;

namespace ALDS1_10_A
{
    class Program
    {
        public void Proc()
        {
            int N = int.Parse(Console.ReadLine());
            int output = fibonacci(N);
            Console.WriteLine(output);
        }

        static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }

        public int fibonacci(int N)
        {
            int[] arr = new int[N + 1];
            arr[0] = 1;
            arr[1] = 1;
            for (int i = 2; i <= N; i++)
            {
                arr[i] = arr[i - 1] + arr[i - 2];
            }
            return arr[N];
        }
    }
}

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

using namespace std;
using ll = long long;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    string ans = "";
    if (a < 0 && b < 0) {
        if ((b - a + 1) % 2 == 1)
            ans = "Negative";
        else
            ans = "Positive";
    }
    else if (a > 0 && b > 0)ans = "Positive";
    else ans = "Zero";

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

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

int N, last, A[100001];
long long ans;

int main(){
	scanf("%d", &N);
	for(int i=0;i<N;i++)scanf("%d", &A[i]);
	for(int i=0;i<N;i++){
		if(A[i]>=last)ans+=(A[i]+last)/2, last=(A[i]+last)%2;
		else last=0;
	}
	printf("%lld\n", ans);
	return 0;
}
/*
8
2
0
1
6
0
8
2
1

4
4
0
3
2
*/

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  map<int, int> cnt;
  vector<int> D(N);
  REP(i, N) {
    int d; cin >> d;
    cnt[d]++;
  }

  int M; cin >> M;
  REP(i, M) {
    int t; cin >> t;
    cnt[t]--;
    if (cnt[t] < 0) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
}

Measured memory_bytes: 10368
#include <stdio.h>
#include <stdlib.h>
int main(){
  int N,j,i=0,*A,num,k=0;

  scanf("%d",&N);
  A = (int *)malloc(N * sizeof(int));

  for(j = 0 ; j < N ; j++) scanf("%d",&A[j]);

  for(i = 0 ; i < N-1 ; i++){
    for(j = N-1 ; j >= i+1 ; j--){ 
      if(A[j] < A[j-1]){
	num = A[j];
	A[j] = A[j-1];
	A[j-1] = num;
	k++; }
    }
  }

  for(j = 0 ; j < N-1 ; j++) printf("%d ",A[j]);
  printf("%d\n",A[j]);
  printf("%d\n",k);
  free(A);

  return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define SIZE 5005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
bool dp[SIZE];
int A[SIZE];
P pos[SIZE];
int main()
{
	int n,K;
	scanf("%d %d",&n,&K);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	sort(A,A+n);
	ll sum=0;
	for(int i=0;i<n;i++) sum+=A[i];
	memset(dp,false,sizeof(dp));
	dp[0]=true;
	int ret=0;
	for(int i=n-1;i>=0;i--)
	{
		bool up=false;
		for(int j=0;j<K;j++)
		{
			if(dp[j]&&j+sum>=K) up=true;
		}
		if(!up) ret++;
		sum-=A[i];
		for(int j=K-1;j>=A[i];j--) dp[j]|=dp[j-A[i]];
	}
	printf("%d\n",ret);
	return 0;
}

Measured memory_bytes: 256
//nani?
#include<bits/stdc++.h>
#define pi acos(-1);
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define f(i,a,b) for( int i = a; i < b ; i++ ) 
#define sor(a) sort( a.begin(), a.end() )
#define rsor(a) sort( a.rbegin(), a.rend() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
//#define inf 1LL<<62
typedef long long ll;
typedef double ld;
using namespace std;
const ll inf=1e9;
const ll MOD=1e9+7;
// ac cmtr;
const ll MAX_N = 1e5;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;}
 
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1<<" | ";
  __f(comma+1, args...);}
#else
#define trace(...)
#endif
//---------------------------

ll a[100005][3];

int main(){
    fastio;
    ll n;
    cin>>n;
    ll ans=0;
    f(i,0,n){
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    f(i,1,n){
        f(j,0,3){
            if(j==0) a[i][j]=max(a[i][j]+a[i-1][1],a[i][j]+a[i-1][2]);
            else if(j==1) a[i][j]=max(a[i][j]+a[i-1][0],a[i][j]+a[i-1][2]);
            else a[i][j]=max(a[i][j]+a[i-1][0],a[i][j]+a[i-1][1]);
        }
    }
    /*f(i,0,n){
        f(j,0,3){
            cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<max(a[n-1][0],max(a[n-1][1],a[n-1][2]))<<endl;




    return 0;
}   



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

ll N, K;
vector<ll> A;
vector<ll> F;

bool solve(ll score){
    ll num = 0;
    REP(i,N){
        ll a = A[i];
        ll f = F[i];
        if(a*f > score){
            ll tmp;
            //tmp = score / f - (score%f == 0);
            tmp = score / f;
            num += a - tmp;
        }
    }

    if(num > K)
        return false;
    else
        return true;
}

int main(){
    cin >> N >> K;
    REP(i,N){
        ll a;
        cin >> a;
        A.push_back(a);
    }
    REP(i,N){
        ll f;
        cin >> f;
        F.push_back(f);
    }

    sort(A.begin(), A.end());
    sort(F.rbegin(), F.rend());

    ll left = 0;
    ll right = LLONG_MAX;
    //ll right = 20;
    REP(i,100){
        ll mid = (left + right) / 2;
        bool ok = solve(mid);
        if(ok){
            right = mid;
        }
        else{
            left = mid;
        }
    }

    cout << right << endl;
    return 0;
}


Measured memory_bytes: 4848
import numpy as np

A, B, C, D = map(int, input().split())
x, y = zip(*sorted(zip([A, B, C, D], [1, -1, 1, -1])))
z = np.diff(x)[np.cumsum(y)[:-1] == 2]
print(z[0] if len(z) == 1 else 0)

Measured memory_bytes: 12392
#!/usr/bin/env python3
import sys

def solve(N: int, A: int, B: int, C: int, D: int, E: int):
    from math import ceil
    return ceil(N / min(A, B, C, D, E)) + 4


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    E = int(next(tokens))  # type: int
    print(solve(N, A, B, C, D, E))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 60;

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

struct UnionFind{
private:
  vector<int> par, rank, sizes;
public:
  UnionFind(int n) : par(n, -1), rank(n, 0), sizes(n, 1){}
  int find(int x) { return (par[x] < 0) ? x : (par[x] = find(par[x])); }
  bool unite(int x, int y){
    x = find(x), y = find(y);
    if(x==y) return false;
    else if(rank[x]<rank[y]){
      par[x] = y;
      sizes[y] += sizes[x];
    } else if(rank[x]>rank[y]){
      par[y] = x;
      sizes[x] += sizes[y];
    } else{
      par[y] = x;
      rank[x] += 1;
      sizes[x] += sizes[y];
    }
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return sizes[find(x)]; }
};

int main() {
  int n, m; cin>>n>>m;
  vector<pair<int, int>> g;
  rep(i, m) {
    int a, b; cin>>a>>b;
    --a; --b;
    g.emplace_back(a, b);
  }

  int ans = 0;
  rep(i, m) {
    UnionFind uf(n);
    rep(j, m) {
      if (i == j) continue;
      uf.unite(g[j].first, g[j].second);
    }
    ans += uf.unite(g[i].first, g[i].second);
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 256
/*----------------by syr----------------*/
/*

         iii                  ii
     rBQBBBBBBE       BBR iBBBBQBBL     XBBBBBBQBBBBB
   iBBQJ    7BBB      BBsSBBr   BBQ      i      cBBB
  rBBU       iBBw     BBBQi     HBBi           KBBi
  BBH         BB5    iBBB       isL          wBB5
 GBB         iBBi    6BB                   iBBB
 BBQ         BQB     BBD                  QBBi
 BBB        BQB     iQBi                1BBv
 sBBg     wBBB      QBB               iBBB
  7BBBBBBBBBi       BBR              wBBBBBBBBBBBBB
     irvi           ii               ii    i i iii
                i5U
               BBB
               BB7
              1BB
      iPBBBBBKBBR    JBR1       rQBO   BR  UBQP  iBBQi
    7BBBGs7sXBBBi     QBBr     gBBE   rBB BB2BB7HBZQBB
   QBBi      sBQ       BBB   iBBB     SQBBR  BBBB  cBQ
  gBQ        BBg        BBB KBBi      MBBH   BBB   BBs
 iBBv       iBBi         QBBBL        BBR   pBB   iBB
 pBB        BBB         iBBBB        iBB    BBL   KBB
 MBB       BBBR        BBB JBBi      DBR   iBQ    BBL
 GBB     7BBBB2      PBBH   BBBi     BQr   DBB   iBB
  BQBXwgBBP BB7    1BBB      BBQ7   1BB    BBc   BBB
   2BBBBw   BB    EBBS        QBBi  HBa   iBB    BB7
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1e9 + 7;

int n, k;

int main(){
	scanf("%d%d", &n, &k);
	printf("%d\n", max(0, n - k + 1));
	return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		int dataset;
		int[] data = new int[3];		
		Scanner scanner = new Scanner(System.in);
		dataset = scanner.nextInt();
		for(int i=0; i<dataset; i++){
			for(int j=0; j<3; j++){
				data[j] = scanner.nextInt();
			}
			Arrays.sort(data);
			if(data[2]*data[2] == (data[0]*data[0] + data[1]*data[1])){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 23396
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int main(){
  long long N;
  cin >> N;
  long long ans;
  for(long long i = 0; i * i <= N; i++){
    ans = i * i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MN 200005
using namespace std;
int n,m,q,a[2][MN];char x[MN],y[MN];
int main(){
	scanf("%s%s",x+1,y+1);n=strlen(x+1),m=strlen(y+1);int l,r,ll,rr;
	for(int i=1;i<=n;i++)a[0][i]=a[0][i-1]+x[i]-'A'+1;
	for(int i=1;i<=n;i++)a[1][i]=a[1][i-1]+y[i]-'A'+1;
	scanf("%d",&q);
	for(int i=1;i<=q;i++){
		scanf("%d%d%d%d",&l,&r,&ll,&rr);
		int tmpx=a[0][r]-a[0][l-1],tmpy=a[1][rr]-a[1][ll-1];
		printf("%s\n",(tmpx-tmpy)%3==0?"YES":"NO");
	}
}



Measured memory_bytes: 1536
A,B,H,M=map(int, input().split())
import math

angle = abs(30*H-5.5*M)
angle = min(angle, 360-angle)*math.pi/180
 
c=A**2 + B**2 -2*A*B* math.cos(angle)
c=c**0.5
 
print(c)

Measured memory_bytes: 9312
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
 
int main(){
	string s;cin>>s;
	int x,y;cin>>x>>y;
	vector<int> v_x;
	vector<int> v_y;
	int tmp = 0;
	int cnt = 0;
	for(int i = 0; i < s.size(); i++) {
		if (s[i] == 'F'){
			tmp++;
		}
		else{
			if (cnt % 2 == 0){
				v_x.pb(tmp);
				cnt ++;
				tmp = 0;
			}
			else{
				v_y.pb(tmp);
				cnt++;
				tmp = 0;
			}
		}
	}
	if (tmp != 0){
		if (cnt % 2 == 0){
			v_x.pb(tmp);
		}
		else{
			v_y.pb(tmp);
		}
	}
	vector<vector<bool>> dp(2,vector<bool>(20000,false));
	dp[0][10000] = true;
	int n = v_x.size();
	for(int i = 0; i < n; i++) {
        for(int k = 0; k < 20000; k++) {
            if (i % 2 == 0){
                dp[1][k] = false;
            }
            else{
                dp[0][k] = false;
            }
        }
		for(int j = 0; j < 20000; j++) {
			if (i % 2 == 0){
				if (dp[0][j]){
					if (i == 0){
						dp[1][j + v_x[i]] = true;
					}
					else{
						dp[1][j + v_x[i]] = true; 
						dp[1][j - v_x[i]] = true; 
					}
				}
			}
			else{
				if (dp[1][j]){
					dp[0][j + v_x[i]] = true;
					dp[0][j - v_x[i]] = true;
				}
			}
		}
	}
	if (!dp[n % 2][10000 + x]){
		cout << "No" << endl;
		return 0;
	}
 
	vector<vector<bool>> dp2(2,vector<bool>(20000,false));
	dp2[0][10000] = true;
	n = v_y.size();
	for(int i = 0; i < n; i++) {
        for(int k = 0; k < 20000; k++) {
            if (i % 2 == 0){
                dp2[1][k] = false;
            }
            else{
                dp2[0][k] = false;
            }
        }
		for(int j = 0; j < 20000; j++) {
			if (i % 2 == 0){
 
				if (dp2[0][j]){
					dp2[1][j + v_y[i]] = true; 
					dp2[1][j - v_y[i]] = true; 
				}
			}
			else{
				if (dp2[1][j]){
					dp2[0][j + v_y[i]] = true;
					dp2[0][j - v_y[i]] = true;
				}
			}
		}
	}
	// for(int i = -15; i < 15; i++) {
	// 	cout << dp2[n % 2][10000 + i] << endl;
	// }
	// for(int i = 0; i < n; i++) {
	// 	cout << v_y[i] << endl;
	// }
	if (!dp2[n % 2][10000 + y]){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
 
	// for(int i = -15; i < 15; i++) {
	// 	cout << dp2[n % 2][10000 + i] << endl;
	// }
	// for(int i = 0; i < n; i++) {
	// 	cout << v_y[i] << endl;
	// }
 
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
#define MOD 998244353
//#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n;
char s[200010];
int f(int l,int len,int flip){
	//[0,len)の方が[l,l+len)より小さければ-1,大きければ1,等しければ0
	len=min(len,n-l);
	rep(i,0,len){
		if((s[i]^flip)=='0'&&s[l+i]=='1')return -1;
		if((s[i]^flip)=='1'&&s[l+i]=='0')return 1;
	}
	return 0;
}

ll d[200010];
int main(){
	scanf("%lld %s",&n,s);
	ll p2=1;
	while(n%2==0)n/=2,p2*=2;
	n*=p2;
	repp(k,p2,n+1,p2)if(n%k==0){
		//k周期
		int flag=0;
		for(int i=1;flag==0&&i<n/k;i++)flag=f(i*k,k,i%2);
		ll ans=0;
		rep(i,0,k)ans=(ans*2+s[i]-'0')%MOD;
		if(flag!=1)ans++;
		d[k]=ans;
//		printf("%d %d %lld\n",k,flag,ans);
	}
	rep(i,1,n)repp(j,i+i,n+1,i)if(n%j==0)d[j]=(d[j]-d[i])%MOD;
	ll ans=0;
	rep(i,1,n+1)ans=(ans+d[i]*i*2)%MOD;
	printf("%lld",(ans+MOD)%MOD);
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stack>
#include <vector> 
#include <iostream>
#define N 100000
using namespace std;

vector<int>  G[N];
int color[N];
int n;

void dfs(int s, int c)
{
    stack<int> st;
    color[s] = c;
    st.push(s);
    while(!st.empty())
    {
        int u = st.top();
        st.pop();
        for (int i = 0; i < G[u].size(); i++)
        {
            int v = G[u][i];
            if(color[v] == -1)
            {
                color[v] = c;
                st.push(v);
            }
        } 
    }
    return;
}

void assignColor()
{
    int id = 1;
    for (int i = 0; i < n; i++)
    {
        color[i] = -1;
    } 
    for (int u = 0; u < n; ++u)
    {
        if(color[u]==-1) dfs(u, id++);
    }

    return;
}

int main()
{
    //freopen("in3.txt","r",stdin);
    int m;
    scanf("%d %d",&n, &m);

    for (int i = 0; i < m; i++)
    {
        int s, t;
        scanf("%d %d",&s,&t); 
        G[s].push_back(t);
        G[t].push_back(s);
    } 

    assignColor(); 

    int q,s,t;
    scanf("%d",&q);
    for (int i = 0; i < q; i++)
    {
        scanf("%d %d",&s,&t);
        if (color[s] == color[t])
        { 
            printf("yes\n"); 
        } else
        { 
            printf("no\n"); 
        } 
    } 
    return 0;
}

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

int main(void) {
  int n, k;
  cin >> n >> k;
  vector<double> ps(n + 1);
  ps[0] = 0;
  double t;
  for (int i = 0; i < n; ++i) {
    cin >> t;
    ps[i + 1] = (t + 1) / 2 + ps[i];
  }

  double result = 0;
  for (int i = k; i <= n; ++i) {
    result = max(result, ps[i] - ps[i - k]);
  }

  cout << std::fixed << std::setprecision(10) << result << endl;
  return 0;
}

Measured memory_bytes: 4824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll m;
  cin >> m;
  ll n=0;
  ll d=0;
  for(ll i=0;i<m;i++) {
    ll tc,td;
    cin >> td >> tc;
    n+=tc;
    d+=td*tc;
  }
  cout << n-1+(d-1)/9 << endl;
}

Measured memory_bytes: 256
import heapq


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M = read_ints()
    AB = []
    for _ in range(N):
        AB.append(read_ints())
    AB.sort(reverse=True)
    rewards = []
    total = 0
    for i in range(M):
        while AB and AB[-1][0] <= i+1:
            a, b = AB.pop()
            heapq.heappush(rewards, -b)
        if rewards:
            total += -heapq.heappop(rewards)
    return total


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 94356
/*ربى اصلح لى شأنى*/
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define el '\n';
long long  gcd(long long  a, long long  b) { return !b ? a : gcd(b, a % b); }
long long  lcm(long long a, long long  b) { return (a / gcd(a, b)) * b; }
long long  fact(long long  n) { return !n ? 1 : n * fact(n - 1); }
using namespace std;
const  double PI = acos(-1);
/* smile ^_^ */
using lli = long long int;
using namespace std;
void ezzo()
{
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);

}
int main()
{
	ezzo();
	lli n, a, b; cin >> n >> a >> b;
	if ((a* n) > b){
		cout << b << el;
	}
	else{
		cout << (a*n) << el;
	}
	//memset(a, 0, sizeof a);//تصفير الاراى 
	//cout << fixed << setprecision(9) << a << el;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;

int64_t gcd(int64_t a, int64_t b) {
	int64_t c;
	while(a) {
		c = a; a = b%a; b = c;
	}
	return b;
}

int main() {
    int N;
    cin >> N;
    i64 ans = -1;
    for(int i = 0; i < N; i++) {
        i64 a;
        cin >> a;
        if(!i) {
            ans = a;
        } else {
            ans = gcd(ans, a);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
using  namespace std;
bool primer(int x)
{
  if(x == 1) return false;
  int i;
  int t = sqrt(x);
  for( i = 2;i<=t;i++)
     if(x%i == 0)
       break;
  if(i>t) return true;
  else return false ;
}
int main ()
{
  int n,a[10000],ans = 0;
  scanf("%d",&n);
  for(int i = 0;i<n;i++)
     scanf("%d",&a[i]);
  for(int i = 0;i<n;i++)
   {
     if(primer(a[i]))
        ans++;
   }
   printf("%d\n",ans);
  return 0 ;
}



Measured memory_bytes: 3196
#include <iostream>
#include <bits/stdc++.h>
#include <deque>
#include <vector>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int n=s.length(),c=0;
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1]) c++;
    }
    cout<<c;
}


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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int N = input();
    vector< int > a(N);
    cin >> a;
    
    auto dp = make_vector(N, N, infll);
    range(i, 0, N) dp[i][i] = 0;
    
    range(d, 1, N) {
        range(r, d, N) {
            int l = r - d;
            i64 size = 0;
            range(i, l, r + 1) size += a[i];
            
            range(m, l, r) {
                chmin(dp[l][r], dp[l][m] + dp[m + 1][r] + size); 
            }
        }
    }
    
    cout << dp[0][N - 1] << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long double ld;
typedef long long ll;

int32_t main() {
    IOS;
    ll t;
    // cin>>t;
    t=1;
    while(t--) {
        int n;
        cin>>n;
        int a[n],b[n],c[n];
        for(int i=0;i<n;i++) {
            cin>>a[i]>>b[i]>>c[i];
        }
        int dp[3][n];
        dp[0][0]=a[0];
        dp[1][0]=b[0];
        dp[2][0]=c[0];

        for(int i=1;i<n;i++) {
            dp[0][i] = a[i]+max(dp[1][i-1],dp[2][i-1]);
            dp[1][i] = b[i]+max(dp[0][i-1],dp[2][i-1]);
            dp[2][i] = c[i]+max(dp[1][i-1],dp[0][i-1]);
        }
        cout<<max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
    }
    return 0;
}

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

public class Program
{
    public static void Main()
    {
        var inputs = Console.ReadLine().Split(" ").Select(str => int.Parse(str)).ToList();
        var h = inputs[0];
        var w = inputs[1];
        var k = inputs[2];

        var fieldInput = new List<string>();
        for (var i = 0; i < h; i++)
        {
            fieldInput.Add(Console.ReadLine());
        }
        var field = fieldInput.Select(str => str.ToCharArray()).ToArray();

        var rowRange = Enumerable.Range(0, h).ToList();
        var powerSetOfRowSelect = PowerSet(rowRange);

        var colRange = Enumerable.Range(0, w).ToList();
        var powerSetOfColSelect = PowerSet(colRange);

        var powerSetOfSelect = powerSetOfRowSelect.SelectMany(
                l => powerSetOfColSelect,
                (rowSelect, colSelect) => new { rowSelect, colSelect });

        var answer = powerSetOfSelect.Count(select =>
        {
            var blackCount = 0;
            for (var rowI = 0; rowI < field.Length; rowI++)
            {
                for (var colJ = 0; colJ < field[rowI].Length; colJ++)
                {
                    if (select.rowSelect.Contains(rowI) ||
                       select.colSelect.Contains(colJ))
                    {
                        continue;
                    }

                    if (field[rowI][colJ] == '#')
                    {
                        blackCount++;
                    }
                }
            }

            if (blackCount == k)
            {
                return true;
            }
            else
            {
                return false;
            }
        });

        Console.WriteLine(answer);
    }

    public static List<List<int>> PowerSet(List<int> nums)
    {
        if (nums.Count == 0)
        {
            var empty = new List<List<int>>();
            empty.Add(new List<int>());
            return empty;
        }

        var head = nums[0];
        var tail = nums.Skip(1).ToList();

        var tailPowerSet = PowerSet(tail);
        var tailPowerSerPlusHead = tailPowerSet.Select(list =>
        {
            var copy = new List<int>(list);
            copy.Add(head);
            return copy;
        }).ToList();
        tailPowerSet.AddRange(tailPowerSerPlusHead);
        return tailPowerSet;
    }
}

Measured memory_bytes: 28440
n=int(input())
import queue
q=queue.Queue()
for i in range(1,10):
    q.put(i)
while n!=0:
    x=q.get();k=x%10
    for j in [10*x+i for i in range(max(0,k-1),min(10,k+2))] :
        q.put(j)
    n-=1
print(x)

Measured memory_bytes: 13040
#include "bits/stdc++.h"
using namespace std;
int main() {
	string s, ans = "Yes";
	int i;

	cin >> s;

	for (i = 0; i < s.length(); i++) {
		if (i % 2 == 0) {
			if (s[i] == 'L') {
				ans = "No";
				break;
			}
		}
		else {
			if (s[i] == 'R') {
				ans = "No";
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  string s;
  cin>>n>>s;
  int best = 0;
  for(int i=0;i<s.length();i++){
  	string a = s.substr(0,i+1);
  	string b = s.substr(i+1,s.length()-1);
  	int dif = 0;
  	sort(a.begin(),a.end());
  	for(int j=0;j<a.length();j++){
  	 if(j==0||a[j]!=a[j-1]){
  	 	for(int s=0;s<b.length();s++){
  	 		if(b[s]==a[j]){
  	 			dif++;
  	 			break;
  	 		}
  	 	}
  	 }
  	}
  	best=max(best,dif);
  }
  cout<<best<<endl;
} 

Measured memory_bytes: 892
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
ll x,a,b;
ll ping[901];
int main(){
	ios::sync_with_stdio(0);
	cin>>x;
	forn(i,-300,301){
		ping[i+300]=(ll)((ll)(i)*(ll)(i)*(ll)(i)*(ll)(i)*(ll)(i));
	}
	rep(i,601){
		rep(j,601){
			if(ping[i]-ping[j]==x){
				cout<<i-300<<" "<<j-300;
				re 0;
			}
		}
	}
	
	re 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;

    string s;
    rep (i, max(a, b))
        s.push_back('0' + min(a, b));

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
array = []
while True:
    n = input()
    if n == "0 0":
        break
    array.append(n.split())

for i in range(len(array)):
    for i2 in range(int(array[i][0])):
        for i3 in range(int(array[i][1])):
            if i2%2 == 0:
                if i3%2 == 0:
                    if i3 == int(array[i][1])-1:
                        print("#")
                    else:
                        print("#",end="")
                else:
                    if i3 == int(array[i][1])-1:
                        print(".")
                    else:
                        print(".",end="")
            else:
                if i3%2 == 0:
                    if i3 == int(array[i][1])-1:
                        print(".")
                    else:
                        print(".",end="")
                else:
                    if i3 == int(array[i][1])-1:
                        print("#")
                    else:
                        print("#",end="")
        if i2 ==int(array[i][0])-1:
            print("")

Measured memory_bytes: 9016
use petgraph::algo::dijkstra;
use petgraph::graph::{NodeIndex, UnGraph};
use proconio::input;

fn main() {
    input! {
        n: usize,
        edges: [(usize, usize, usize); n-1],
        q: usize,
        k: usize,
        pairs: [(usize, usize); q],
    }

    let g = UnGraph::<usize, usize, usize>::from_edges(&edges);
    let res = dijkstra(&g, NodeIndex::new(k), None, |e| *e.weight());


    for (start, end) in &pairs {
        let distance =
            res.get(&NodeIndex::new(*start)).unwrap() + res.get(&NodeIndex::new(*end)).unwrap();
        println!("{}", distance);
    }
}


Measured memory_bytes: 19292
def main():
    n, k = map(int, input().split())
    s = list(map(int, input().split()))
    inf = 10 ** 8
    dp = [inf] * n
    dp[0] = 0

    for j in range(1, n):
        buf = [dp[i] + abs(s[j]-s[i]) for i in range(max(0, j - k), j)]
        dp[j] = min(buf)
    print(dp[-1])

if __name__ == "__main__":
    main()


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    char a; cin >> a;
    if (a < 'a') cout << "A" << endl;
    else cout << "a" << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>

int main()
{
	int N, A, B;
	std::cin >> N >> A >> B;
	int qualifiers = 0;
	int int_order = 0;
	for (int i=1; i<=N; i++) {
		char c;
		std::cin >> c;
		if (c == 'a') {
			if (qualifiers < A+B) {
				std::cout << "Yes" << std::endl;
				qualifiers++;
			}
			else std::cout << "No" << std::endl;
		}
		else if (c == 'b') {
			if (qualifiers < A+B && int_order < B) {
				std::cout << "Yes" << std::endl;
				qualifiers++;
				int_order++;
			}
			else std::cout << "No" << std::endl;
		}
		else std::cout << "No" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(void) {
	int n;
	int h, m, s;
	cin >> n;
	m = n / 60;
	s = n % 60;
	h = m / 60;
	m = m % 60;
	cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n, k;
    cin >> n >> k;
    int h[n];
    rep(i,n)cin >> h[i];

    int dp[n] = {};
    srep(i,1,n)dp[i] = 1001001001;

    rep(i,n){
        srep(j,1,k+1){
            if(i + j >= n)continue;
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }

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


Measured memory_bytes: 1024
inputs = gets.chomp.split(" ")

a_price = inputs[0].to_i
b_price = inputs[1].to_i
c_price = inputs[2].to_i
a_cnt = inputs[3].to_i
b_cnt = inputs[4].to_i


one = a_price * a_cnt + b_price * b_cnt

if a_cnt < b_cnt
  two = c_price * b_cnt * 2
  three = (c_price * a_cnt * 2) + b_price * (b_cnt - a_cnt)
else
  
  two = c_price * a_cnt * 2
  three = (c_price * b_cnt * 2) + a_price * (a_cnt - b_cnt)
end

small = one
small = two if two < small
small = three if three < small

puts small

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,r,t;
	cin>>n>>r>>t;
	int p[100],now[100],tmp[1000],bottle[1000];
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	for(int i=0;i<1000;i++){
		bottle[i]=0;
		tmp[i]=0;
	}
	for(int i=0;i<100;i++)now[i]=p[i];
	for(int i=0;i<t;i++){
		for(int j=0;j<n;j++){
			bottle[now[j]]=max(bottle[now[j]]-1,0);
		}
		for(int j=0;j<r;j++)bottle[j]+=tmp[j];
		for(int j=0;j<r;j++)tmp[j]=0;
		for(int j=0;j<n;j++){
			now[j]=(now[j]+p[j])%r;
			tmp[now[j]]++;
		}
	}
	for(int j=0;j<r;j++)bottle[j]+=tmp[j];
	int ans=0;
	for(int i=0;i<r;i++){
		ans+=bottle[i];
	}
	cout<<ans<<endl;
}

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

int main(){    
    int N; cin >> N;
    int ans = 0;

    for (int i = 1; i <= N; i++)
    {
        int a; cin >> a;
        if (i%2 == 1 && a%2 == 1)
        {
            ans++;
        }
        
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define ll long long
#define F(type, i, a, b) for(type i = a; i <= b; i ++)
#define RF(type, i, a, b) for(type i = a; i >= b;i --)
#define sz(a) sizeof(a)
#define deb(a) cerr<<" ["<<#a<<"->"<<a<<"] "
#define name(a) cerr<<" ["<<#a<<"->"
#define next_line cerr<<'\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for(auto it = s.begin(); it != s.end(); it ++)

using namespace std;

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

ll INF = 1e18 + 1LL;

void solve()
{
    ll n, k;
    cin>>n>>k;
    ll Perm[n], cost[n];
    F(ll, i, 0, n - 1){
        cin>>Perm[i];
        Perm[i]--;
    }
    F(ll, i, 0, n - 1)
        cin>>cost[i];
    vector<vector<ll> > conn, ans_c;
    vector<int> comp(n, -1);
    int ls_c = 0;
    F(ll, i, 0, n - 1){
        stack<ll> st;
        if(comp[i] == (-1)){
            vector<ll> pu;
            st.push(i);
            while(!st.empty()){
                ll top = st.top();
                st.pop();
                pu.push_back(top);
                comp[top] = ls_c;
                if(comp[Perm[top] ] == (-1)){
                    st.push(Perm[top]);
                }
            }
            conn.push_back(pu);
            ls_c ++;
        }
    } 
    for(vector<ll> &v: conn){
        ll s = v.size();
        vector<ll> pu;
        ll add = 0LL, max_co;
        F(ll, j, 1, s){
            add += cost[v[j - 1] ];
            max_co = add;
            ll mov_add = add;
            F(ll, i, 1, s - 1){
                mov_add -= cost[v[i - 1]];
                mov_add += cost[v[(i + j - 1) % s]];
                max_co = max(max_co, mov_add);
            }
            pu.push_back(max_co);
        }
        ans_c.push_back(pu);
    }
    ll ans = -INF;
    for(vector<ll> &v: ans_c){
        ll size = v.size();
        if(v.back() <= 0LL){
            size = min(size, k);
            ans = max(ans, *max_element(v.begin(), v.begin() + size));
        }
        else{
            ll cyc = k / size, add = ((k % size) != 0LL)?*max_element(v.begin(), v.begin() + (k % size)):0LL;
            ans = max(ans, (cyc * v.back()) + add);
            if(cyc >= 1){
                ans = max(ans, ((cyc - 1LL) * v.back()) + *max_element(all(v)));
            }
        }
    }    
    cout<<ans<<'\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        //freopen("Debug.txt", "w", stderr);
    #else
    #endif
        solve();
}


Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll a,b,s;
    cin>>a>>b;
    s=a+b;
    s=max(s,a+b);
    s=max(s,a-b);
    s=max(s,a*b);
    cout<<s;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpii;
typedef vector<pair<ll, ll> > vpll;

#define pll pair<ll,ll>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define F first
#define S second
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define watch(x) cout << (#x) << " is " << (x) << endl
#define sz(a) int((a).size())
#define endl '\n' // remove for interactive

const int INF = 1e9;
const ll mod = 1e9 + 7;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



void solve()
{
    int n; cin>>n;
    ll ans = 1;
    REP(i, 1, n) ans = ans * 10 % mod;
    ll sub1 = 1;
    REP(i, 1, n) sub1 = sub1 * 9 % mod;
    // sub1 = (sub1-1+mod) % mod;
    ll sub2 = sub1;
    ll sub3 = 1;
    REP(i, 1, n) sub3 = sub3 * 8 % mod;
    sub2 = (sub2-sub3+mod)% mod;
    sub1 = sub2;
    ans = (ans-sub1+mod)%mod;
    ans = (ans-sub2+mod)%mod;
    ans = (ans-sub3+mod)%mod;
    // ll add = 1;
    cout<<ans;
    
    
}

int main()
{
    // clock_t start, end;
    // start = clock();
    ios_base::sync_with_stdio(0); //cant use scanf, printf
    cin.tie(0);cout.tie(0); // no longer auto flush cout before each cin, remove for interactive
    int t = 1;
    // cin>>t;
    REP(i, 1, t)
    {
        solve();
        
    }
    // end = clock();
    // double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    // watch(time_taken);
    ll x = INF; x++;
    return 0;
    
}



/*before sub
TEST: 0(1 by 1 too), 1, equal, -ve, bounds(random and ez)
ERR/WA: loop vars, out of bounds, endl, finish taking inputs, large doubles, larger INF, corr mod, t, early/late mod
RE: double dec, integer overflow(ll or 1LL mult)
*/





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

    const int MOD = 1000000007;
    const double PI = acos(-1); 

    //long long
    using ll = long long;

    //出力系
    #define print(x) cout << x << endl
    #define yes cout << "Yes" << endl
    #define YES cout << "YES" << endl
    #define no cout << "No" << endl
    #define NO cout << "NO" << endl
    
    // begin() end()
    #define all(x) (x).begin(),(x).end()

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

    //最大公約数（ll）
    ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

    //素因数分解
    vector<pair<ll, int>>factorize(ll n){
      vector<pair<ll, int>> res;
      for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
          n /= i;
          res.back().second++;
        }
      }
    if(n != 1) res.emplace_back(n, 1);
    return res;
    }



  // // 二分探索(最小値を出す問題は疑う)
  // bool C(ll x){
  //     ll res = 0;
  //     for(int i = 0; i < N; ++i){
  // 		res += max(0ll, A[i]-x/F[i]);
  //     }
  //     return res <= K;
  // }

  //   ll binary_search(ll ok, ll ng){
  //     while(abs(ok - ng) > 1){
  //       ll mid = (ok + ng) / 2;
  //       if(C(mid)) ok = mid;
  //       else ng = mid;
  //     }
  //     return ok;
  //   }


  int main(){
      int N;
      cin >> N;
      vector<int> C(N - 1), S(N - 1), F(N - 1);
      REP(i, N - 1) cin >> C[i] >> S[i] >> F[i];

      REP(i, N){
        int t = 0;
        for(int j = i; j < N - 1; j++){
          if(t < S.at(j)) t = S.at(j);
          else if(t % F.at(j) == 0) ;
          else t = t + (F.at(j) - t % F.at(j));
          t += C.at(j);  
        }

        print(t);
      }
  }

Measured memory_bytes: 256
N,K = map(int,input().split())
vote = [0 for i in range(41)]
for i,x in enumerate(input().split()):
    for j,y in enumerate(str(bin(int(x)))[2:][::-1]):
        vote[40-j] += int(y)

binK = [int(x) for x in str(bin(K))[2:]]
largest_list = [0 if x > N/2 else 1 for x in vote][-len(binK):]

for i,x in enumerate(largest_list):
    if binK[i] == 1 and x == 0:
        break
    if binK[i] == 0 and x == 1:
        largest_list[i] = 0

maxf=0

for i,x in enumerate(largest_list[::-1]):
    maxf += (2**i) * (N-vote[40-i]) if x==1 else (2**i) * vote[40-i]
for i in range(len(largest_list),41):
    maxf += (2**i) * vote[40-i]

print(int(maxf))

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

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    for (int i = 0; i <= k; i++) {
        for (int j = 0; j + i <= k; j++) {
            for (int l = 0; j + i + l <= k; l++) {
                if (l < 0) continue;

                int a_ = a * pow(2, i), b_= b * pow(2, j), c_ = c * pow(2, l);
                if (a_ < b_ && b_ < c_) {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    
    cout << "No" << endl;
}

Measured memory_bytes: 4096