akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<cctype>
using namespace std;
int main(){
	char ch;
	while(1){
		scanf("%c",&ch);
		if(isalpha(ch)){
			if(islower(ch))cout<<(char)toupper(ch);
			else if(isupper(ch))cout<<(char)tolower(ch);
		}
		else {cout<<ch;}
		if(ch=='\n')break;
	}
return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define oo 200000000000
#define inf 1000000000000000000
#define M  1000000007
#define M2 1000000009
#define M3 998244353
typedef long long ll;
using namespace std;
const int N = 305001;
const long double PI = acos(-1);

int ctr;
string s;

signed main(){
    cin >> s;
    for(int i = 0 ; i < s.size() ;i++)ctr+=s[i]=='o';
    ctr+=15-s.size();
    cout << (ctr>7?"YES":"NO") << endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
   string x,s;
cin>>x;

 
for(int i=0;i<x.size();i++){
	if(s.size()==0&&x[i]=='B'){
		continue;
	}
if(x[i]!='B'){
s.push_back(x[i]);
}
else
s.pop_back();
}
for(int i=0;i<s.size();i++){
cout<<s[i];
}
return 0;
}

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

int main(){
  int64_t N,Z=0;
  cin>>N;
  vector<int64_t> p(N);
  for(int64_t i=0;i<N;i++){
    cin>>p[i];
    p[i]-=i;
    p[i]--;
  }
  sort(p.begin(),p.end());
  int64_t A=p[N/2];
  for(int i=0;i<N;i++){
    Z+=abs(A-p[i]);
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 4772
//33
#include<cstdio>
#include<complex>

using namespace std;

int main(){
  for(double x,y,xx,yy,xxx,yyy;scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x,&y,&xx,&yy,&xxx,&yyy)==6;){
    typedef complex<double> P;
    P p(x,y),pp(xx,yy),ppp(xxx,yyy),r;
    r=p+polar(abs(ppp-p),2*arg(pp-p)-arg(ppp-p));
    printf("%4f %4f\n",r.real(),r.imag());
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long long> a(n);
    long long m = 0;
    for(int i = 0;i < n;i++)cin >> a[i];
    sort(a.begin(),a.end());
    if(a[0] < 0 && a[n-1] > 0){//正負
        for(int i = 0;i < n;i++){
            m += abs(a[i]);
        }
        cout << m << endl;
        int i = n-2;
        while(a[i] > 0){
            cout << a[0] << " " << a[i] << endl;
            a[0] -= a[i];
            i--;
        }
        i = 0;
        while(a[i] <= 0){
            cout << a[n-1] << " " << a[i] << endl;
            a[n-1] -= a[i];
            i++;
        }
    }else if(a[0] < 0){//負のみ
        for(int i = 0;i < n-1;i++){
            m += abs(a[i]);
        }
        m += a[n-1];
        cout << m << endl;
        int x = a[n-1];
        int y;
        for(int i = 0;i < n-1;i++){
            y = a[i];
            cout << x << " " << y << endl;
            x -= y;
        } 
    }else{//正のみ
        for(int i = 1;i < n;i++){
            m += a[i];
        }
        m -= a[0];
        cout << m << endl;
        for(int i = 1;i < n-1;i++){
            cout << a[0] << " " << a[i] << endl;
            a[0] -= a[i];
        }
        cout << a[n-1] << " " << a[0] << endl;
    }
    //cin >> n;
}

Measured memory_bytes: 2688
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;

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


Measured memory_bytes: 256
import math
import time
start=time.time()
K=int(input())
ans=0
if K%2==0:
    print(-1)
else:
    if K%7==0:
        K//=7
    k=1
    kk=1
    while True:
        now=time.time()
        if (now-start)>1.8:
            ans=-1
            break
        kk*=10
        kk%=9*K
        if kk==1:
            ans=k
            break
        else:
            k+=1


    print(ans)




Measured memory_bytes: 72996
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> ivec;
const ll N = 1e9+7;
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void clear(queue<P> &q){
    queue<P> empty;
    swap(q,empty);
}


int main(){
    int h,w; cin >> h >> w;
    string s[h];
    rep(i,h) cin >> s[i];
    int isblack[h][w] = {};
    int count[h][w] = {};
    // rep(i,h)rep(j,w) count[i][j] = N;
    // なんかREになる、明日の俺がんばれ
    queue<P> que;
    rep(i,h)rep(j,w){
        if(s[i][j] == '#'){
            count[i][j] = 0;
            isblack[i][j] = 1;
            que.push(P(i,j));
        }
    }
    while(que.size()){
        P p = que.front();que.pop();
        int tx = p.first, ty = p.second;
        rep(i,4){
            int nx = tx + dx[i], ny = ty + dy[i];
            if(isblack[nx][ny] == 0 && nx < h && 0 <= nx && ny < w && 0 <= ny){
                que.push(P(nx,ny));
                isblack[nx][ny] = 1;
                count[nx][ny] = count[tx][ty] + 1;
            }
        }
        // rep(i,h){
        //     rep(j,w){
        //         cout << count[i][j] << " ";
        //     }
        //     cout << endl;
        // }
        // cout << endl;
    }
    int ans  = 0;
    rep(i,h)rep(j,w) ans = max(ans,count[i][j]);
    cout << ans << endl;
    // 以下TLE実装
    // int moved[h][w];
    // // int count[h][w];
    // rep(i,h)rep(j,w) {
    //     moved[i][j] = N;
    //     // count[i][j] = N;
    // }
    // vector<P> start;
    // rep(i,h)rep(j,w) if(s[i][j] == '#') {
    //     moved[i][j] = 0;
    //     start.pb(P(i,j));
    // }

    // int ans = 0;
    // queue<P> que;
    
    // for(auto i : start){
    //     que.push(i);
    //     // count[i][j] = 0;
    //     int count[h][w] = {};
    //     while(que.size()){
    //         P p = que.front();que.pop();
    //         int tx = p.first, ty = p.second;
    //         rep(k,4){
    //             int nx = tx + dx[k], ny = ty + dy[k];
    //             if(nx < h && 0 <= nx && ny < w && 0 <= ny && count[nx][ny] == 0 && (count[tx][ty]+1) <= moved[nx][ny]){
    //                 count[nx][ny] = count[tx][ty] + 1;
    //                 moved[nx][ny] = count[tx][ty] + 1;
    //                 que.push(P(nx,ny));
    //                 // tans = max(tans,count[nx][ny]);
    //                 // cout << nx << ' ' << ny << endl;
    //             }
    //         }
    //     }
    //     clear(que);
    // }

    // rep(i,h)rep(j,w) ans = max(ans,moved[i][j]);

    // cout << ans << endl;
}

Measured memory_bytes: 17296
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  bool issat = true;
  string s;cin >> s;
  rep(i,s.length()){
    if(i%2==0 && s[i] == 'L') issat = false;
    if(i%2==1 && s[i] == 'R') issat = false;
  }
  YesNo(issat);
  return 0;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int cnt=0;
    s.erase(unique(s.begin(), s.end()), s.end());
    cout << s.size() << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    long long h;
    cin >> h;
    
    long long sol = 0, log = 1;
    
    while(h > 1){
    	sol += log;
    	h /= 2;
    	log *= 2;
	}
	
	sol += log;
	
	cout << sol;

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define rep(i,n) for(int i=0; i<n; i++)

int main(void){
    int x;
    scanf("%d", &x);

    if(x <= 599) printf("8\n");
    else if(x<=799) printf("7\n");
    else if(x<=999) printf("6\n");
    else if(x<=1199) printf("5\n");
    else if(x<=1399) printf("4\n");
    else if(x<=1599) printf("3\n");
    else if(x<=1799) printf("2\n");
    else if(x<=1999) printf("1\n");

    return 0;
}

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

using namespace std;

int main(){
  int n,l;
  cin >> n >> l;

  int sum = 0;
  int abs_min = 999999;
  int apple_taist = 0;
  for(int i=1; i<=n; i++){
    int taist = l + i - 1;
    sum += taist;
    if( abs_min > abs(taist) ){
      abs_min = abs(taist);
      apple_taist = taist;
    }
  }
  cout << sum - apple_taist;

  return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int n;cin>>n;
    int nn=(n+1)/2;

    double a=nn,b=n;

    cout<<fixed<<setprecision(10)<<a/b<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const double PI=3.14159265358979323846;
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "

int main(void){
    int n;cin>>n;
    priority_queue<double,vector<double>, greater<double>> q;
    rep(i,n){double tmp;cin>>tmp;q.push(tmp);}
    rep(i, n-1){
        double a=q.top();q.pop();
        double b=q.top();q.pop();
        q.push((a+b)/2);
    }
    co(q.top());
}

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

using namespace std;


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

    int a,b,c;
    a = N % 10;
    b = ((N - a) / 10) % 10;
    c = (N - 10*b - a) / 100;
    if(a==b && b==c){
        cout << N << endl;
    }  
    else if(c*100+c*10+c>N){
        cout << c*100 + c*10 + c << endl;
    }
    else{
        c = c + 1;
        N = c * 100 + c * 10 + c;
        cout << N << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int x,a[10010],ans=0;
   cin>>x;
   for(int i=1;i<=x;i++){
   	cin>>a[i];
   	if(i%2!=0){
   		if(a[i]%2!=0) ans++;
	   }
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	string s;
	cin>>s;

	ll ans = 0;
	vector<int> R(n+1,0);
	vector<int> G(n+1,0);
	vector<int> B(n+1,0);
	R[n]=G[n]=B[n]=0;
	for(int i=n-1;i>=2;i--)
	{
		R[i] = R[i+1] + (s[i]=='R');
		G[i] = G[i+1] + (s[i]=='G');
		B[i] = B[i+1] + (s[i]=='B');
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n-1;j++)
		{
			int d = j-i;
			if((s[i]=='R'&&s[j]=='G')||(s[i]=='G'&&s[j]=='R'))
			{
				ans+=B[j+1];
				if(j+d<n&&s[j+d]=='B')ans--;
			}
			if((s[i]=='R'&&s[j]=='B')||(s[i]=='B'&&s[j]=='R'))
			{
				ans+=G[j+1];
				if(j+d<n&&s[j+d]=='G')ans--;
			}
			if((s[i]=='G'&&s[j]=='B')||(s[i]=='B'&&s[j]=='G'))
			{
				ans+=R[j+1];
				if(j+d<n&&s[j+d]=='R')ans--;
			}
		}
	}
	cout<<ans;
}


Measured memory_bytes: 3656
#include<stdio.h>
#include<stdbool.h>
int main(void){
    int N;
    bool flag=false;
    scanf("%d",&N);
    if(N%2==0){
    char* str;
    str = (char *)malloc(sizeof(char)*N);
    char *str2;
    str2 = (char *)malloc(sizeof(char)*N/2);
    scanf("%s",str);
    for(int i=0;i<N/2;i++){
        str2[i] = str[i];
    }
        str2[N/2]='\0';
    for(int i=N/2;i<N;i++){
        if(str[i]!=str2[i-(N/2)]){
            flag = true;
        }
    }
    if(flag!=true){
        printf("Yes");
    }else{
    	printf("No");
    }
    }else{
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
/*
g++ --std=c++17 A.cpp
*/

#include <iostream>
#include <iomanip> //! for setprecision(20)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;
using mint = static_modint<MOD>;

/*
  == AC Library Cheat sheet
  documentation: file:///Users/nobu/Downloads/ac-library/document_ja/index.html

  mint
    mint m.pow(int p)  //! return m^p
    mint m.inv() //! returns i that gives (m * i).val() == 1 
    int m.val() 

  fenwick_tree (BIT)
    fenwick_tree<T> fw(int n) //! init a[0] .. a[n-1] with all 0
    void fw.add(int idx, T x); //! a[idx] += x
    T fw.sum(int l, int r); //! return a[l] + .. + a[r-1]

  dsu (UnionFind)
    dsu d(int n)  //! prepare dsu with n nodes
    void d.merge(int x, int y)  //! connect node x and y
    bool d.same(int x, int y)  //! return true if node x and y are connected
    int d.leader(int x)  //! return the leader node of the connected group
    int d.size(int x) //! return the size of the group that node x belongs to
    vector<vector<int>> d.groups() //! return a vector of vectors that contain the nodes in each group

    
*/

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

    int n, q;
    cin >> n >> q;
    fenwick_tree<LL> fw(n);
    rep(i, n) {
        int a;
        cin >> a;
        fw.add(i, a);
    }

    rep(i, q) {
        int t;
        cin >> t;
        if (t == 0) {
            int p, x;
            cin >> p >> x;
            fw.add(p, x);
        } else if (t == 1) {
            int l, r;
            cin >> l >> r;
            cout << fw.sum(l, r) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8240
n = int(input())
z = list(map(int,input().split()))

def half(n,z):
	existodd = 0
	count = 0
	while True: 
		for i in z:
			if i % 2 != 0:
				existodd = 1

		if existodd:
			print(count)
			break
		
		for i in range(n):		
			z[i] /= 2
		
		count += 1
	
half(n,z)


Measured memory_bytes: 3060
s=input()
t=input()
scorelist=[]
for i in range(len(s)-len(t)+1):
  S=s[i:i+len(t)]
  score=0
  for j in range(len(t)):
    if S[j]!=t[j]:
      score+=1
  scorelist.append(str(score))
point=min(scorelist)
print(point)


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

int main(){
    int N;  cin >> N;
    vector<int> A(N+1, 0);
    for(int i=0; i<N+1; i++) cin >> A[i];
    vector<int> B(N,0);
    for(int i=0; i<N; i++) cin >> B[i];

    ll ans = 0;
    for(int i=0; i<N; i++){
        ll beat1 = min(A[i], B[i]);
        A[i] -= beat1;
        B[i] -= beat1;

        ll beat2 = min(A[i+1], B[i]);
        A[i+1] -= beat2;
        B[i] -= beat2;
        ans += beat1 + beat2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define INF 1000000009
#define LINF 1000000000000000009
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
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 (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }
ll mod = 1000000007;

ll fac[2000010];

ll modinv(ll a) {
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}

void modfac() {
	fac[0] = 1;
	for (ll i = 1; i < 2000010; i++) {
		fac[i] = (fac[i - 1] * i) % mod;
	}
}

ll modperm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	else return (fac[n] * modinv(fac[n - k])) % mod;
}

ll modcomb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	else return ((fac[n] * modinv(fac[k])) % mod*modinv(fac[n - k])) % mod;
}

int main() {
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (s == u) cout << a - 1 << ' ' << b << endl;
	else cout << a << ' ' << b - 1 << endl;
}

Measured memory_bytes: 256
console.log((args=>{
  const [[N],D,[M],T] = args.trim().split('\n').map(r=>r.split(' ').map(v=>v|0));
  D.sort((a,b)=>a-b);
  T.sort((a,b)=>a-b);
  let j = -1;
  Q: for ( let i = 0; i < M; i++ ) {
    while ( ++j < N ) {
      if ( D[j] > T[i] ) return 'NO';
      if ( D[j] === T[i] ) continue Q;
    }
    return 'NO';
  }
  return 'YES';
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 61292
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3","sse2","sse")
#pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC diagnostic error "-std=c++14"
#include "bits/stdc++.h"
//#include "ext/pb_ds/tree_policy.hpp"
//#include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) (x&(-x))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9+7;
const ll inf = 1e9+7;
const ld eps = 1e-9;
const db PI = atan(1)*4;
template<typename T>
inline int sign(const T&a) {
    if(a<0)return -1;
    if(a>0)return 1;
    return 0;
}

template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}

template<typename T> inline void in(T &x) {
    x = 0;
    T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (isdigit(ch))  {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    x *= f;
}

ll twop(int x) {
    return 1LL<<x;
}

template<typename A,typename B > inline void in(A&x,B&y) {
    in(x);
    in(y);
}
template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z) {
    in(x);
    in(y);
    in(z);
}
template<typename A,typename B,typename C,typename D> inline void in(A&x,B&y,C&z,D&d) {
    in(x);
    in(y);
    in(z);
    in(d);
}

namespace SOLVE {
    int ds(int n){
        if(n<10)return n;
        return ds(n/10)+n%10;
    }
    void main(){
        int n;cin>>n;
        int ans = inf;
        REP(i,1,n){
            upmin(ans, ds(i)+ds(n-i));
        }
        cout<<ans;
    }
}


int main() {

    
    
    
    
    
    
    
    
    
    SOLVE::main();
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
def combination(n, r):
    r = min(n - r, r)
    result = 1
    for i in range(n, n - r, -1):
        result *= i
    for i in range(1, r + 1):
        result //= i
    return result


N, A, B = map(int, input().split())
v_list = list(map(int, input().split()))
v_list.sort(reverse=True)

mean_max = sum(v_list[:A]) / A
comb = 0
if v_list[0] != v_list[A-1]:
    x = v_list.count(v_list[A-1])
    y = v_list[:A].count(v_list[A-1])
    comb = combination(x, y)
else:
    x = v_list.count(v_list[A-1])
    for i in range(A, B+1):
        if v_list[i-1] == v_list[0]:
            comb += combination(x, i)

print(mean_max)
print(comb if comb != 0 else 1)


Measured memory_bytes: 3188
flg = [1] * (10**5+1)
flg[0], flg[1] = 0, 0
for i in range(2,10**5+1):
	if flg[i] == 1:
		for j in range(2*i, 10**5+1, i):
			flg[j] = 0

cnt = [0,0]
tmp = 0
for i in range(2,10**5+1):
	if flg[i] == 1:
		if flg[(i+1)//2] == 1:
			tmp += 1
			cnt.append(tmp)
		else:
			cnt.append(tmp)
	else:
		cnt.append(tmp)

Q = int(input())
ans = []

for _ in range(Q):
	tl,tr = map(int, input().split())
	ans.append(cnt[tr] - cnt[tl-1])

for a in ans:
	print(a)

Measured memory_bytes: 9332
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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() {
  int N, M;
  cin >> N >> M;

  vector<int> P(M), Y(M);
  vector<vector<int>> PY(N);

  rep(i, M) {
    cin >> P[i] >> Y[i];
    P[i]--;
    PY[P[i]].pb(Y[i]);
  }

  rep(i, N) { sort(all(PY[i])); }

  rep(i, M) {
    int l = P[i] + 1;
    int r = lower_bound(all(PY[P[i]]), Y[i]) - PY[P[i]].begin() + 1;
    cout << setfill('0') << std::right << std::setw(6) << l << setfill('0')
         << std::right << std::setw(6) << r << endl;
  }
}

Measured memory_bytes: 7808
<?php
fscanf(STDIN, "%d", $n);
$b = explode(' ', trim(fgets(STDIN)));
array_reverse($b);

$result = 0;
$a = [];
$a[] = $b[0];
for ($i=0; $i < count($b); $i++) { 
    $current = $b[$i];
    $next = isset($b[$i+1]) ? $b[$i+1] : $b[$i];
    
    if ($current <= $next) {
        $a[] = $current;
    } else {
        $a[] = $next;
    }    
}
echo array_sum($a) . "\n";

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

int main() {
  int N, K, A=0, B=0;
  cin >> N;
  
  vector<int> count(100, 0);
  
  for (int i=0; i<N; i++) {
    cin >> K;
    count.at(K-1) ++;
  }
  
  for (int i=0; i<((N+1)/2); i++) {
    for (int j=100; j>0; j--) {
      if (count.at(j-1) != 0){
        A += j;
        count.at(j-1) --;
        break;
      }
    }
    for (int j=100; j>0; j--) {
      if (count.at(j-1) != 0){
        B += j;
        count.at(j-1) --;
        break;
      }
    }
  }
  
  cout << A-B << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int a,b,n;
  cin>>n>>a>>b;
  string s;
  cin>>s;
  int count=0,countb=0;
  rep(i,n){
    bool fg=false;
    if(s[i]=='a'){
      if(count<a+b){
        count++;
        fg=true;
      }
      else{
        fg=false;
      }
    }
    else if(s[i]=='b'){
      if(count<a+b){
        if(countb<b){
          count++;
          countb++;
          fg=true;
        }
        else{
          fg=false;
        }
      }
      else{
        fg=false;
      }
    }
    if(fg){
      cout<<"Yes"<<'\n';
    }
    else{
      cout<<"No"<<'\n';
    }
  }
  return(0);
}


Measured memory_bytes: 848
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int N = IN();
	OUT(N / 3);
}

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

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

	int l,r;
	for(int i=0;i<n;i++){
		cin>>l>>r;
		ans+=r-l+1;
	}

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

signed main(){
	int n; cin>>n;
	char memo;
	bool ok=true;
	map<string,int> mp;
	rep(i,0,n){
		string s; cin>>s;
		if(mp[s])ok=0;
		if(i!=0)if(s[0]!=memo)ok=0;
		mp[s]++;
		memo=s[s.size()-1];
	}
	cout<<(ok ? "Yes":"No")<<endl;

	return 0;
}

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

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

Measured memory_bytes: 384
#include <stdio.h>
int main(){
    int i,b=0,n,k;
    scanf("%d",&n);
    int a[n];
    scanf("%d",&k);
    for (i=0;i<n;i++){
        scanf("%d",a+i);
        if (a[i]>=k)
            b++;
    }
    printf("%d",b);
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<queue>
using namespace std;
long long f[101010];
long long x[101010];
long long E,T;
long long calc(int i,int j)
{
	return max(f[j-1]+T,f[j-1]+2*x[i]-2*x[j]);
}
priority_queue<long long> Q;
int main()
{
	int n;
	cin>>n>>E>>T;
	for(int i=1;i<=n;i++)
		cin>>x[i];
	f[1]=T;
	int now=0;
	for(int i=2;i<=n;i++)
	{
		f[i]=f[i-1]+T;
		int l=1,r=i-1;
		while(r>l)
		{
			int m=(l+r)/2;
			if(T-2*x[i]+2*x[m]>=0)
				r=m;
			else
				l=m+1;
		}
		f[i]=min(f[i],max(f[l-1]+T,f[l-1]+2*x[i]-2*x[l]));
		if(l>1)
		{
			while(now<l-1)
			{
				now++;
				Q.push(2*x[now]-f[now-1]);
			}
			f[i]=min(f[i],2*x[i]-Q.top());
		}
	}
	cout<<f[n]+E<<endl;
	return 0;
}

Measured memory_bytes: 2936
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O20")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = long long; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(
2
1
2 0
1
1 0
)X";
stringstream iss{text};
#endif

class HonestOrUnkind2
{
	ll N{0};
	vector<bool> h;//正直かどうかの仮定
	vector<vector<ll>> s;//証言
	void inp( ) {
		iss >> N;
		h.resize(N);
		s.resize(N, vector<ll>(N, 3));//3:言及せず 0:不親切呼ばわり 1:正直者認定
		rep(n, N) {
			ll K; iss >> K;//証言個数
			rep(k, K) {
				ll p, hn; iss >> p >> hn;//p番目の人は(n番が言うには)正直か
				s[n][--p] = hn;
			}
		}
	}
	inline bool consistentQ( ) {//仮定と矛盾しないかだけ調べる
		for (ll n = 0; n < N; ++n) {
			if (!h[n]) continue; //不親切なら無視
			for (ll p = 0; p < N; ++p) {//n番目の人がp番目の人に対して証言		
				if (s[n][p] == 3) continue;
				if ((s[n][p] == 1) && !h[p]) return false;
				if ((s[n][p] == 0) && h[p]) return false;
			}
		}
		return true;
	}
	void changeSeikaku( ) {
		size_t NH{0}; // 正直者の最大人数
		const ll maxB{(1 << N)};
		for (ll b = 0; b < maxB; ++b) {//全員の状態を変える
			rep(n, N) { h[n] = (b >> n) & 1; }//n番の人が正直と仮定したか
			if (consistentQ( )) NH = max(NH, bitset<32>(b).count( ));
		}
		p(NH);
	}
public:
	void procedures( ) {
		inp( );
		changeSeikaku( );
	}
};

int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	class HonestOrUnkind2 a; a.procedures( );
}

Measured memory_bytes: 3616
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <utility>
#include <iostream>

using namespace std;

const int N = 100'009;

long long a[N];
int o[N];
int cnt[N];

int main() {
  int n;
  scanf("%d", &n);
  map<long long, int> w;
  for (int i = 0; i < n; ++i) {
    scanf("%lld", a + i);
    w[a[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    o[i] = i;
  }
  sort(o, o + n, [](int i, int j) {
    return a[i] > a[j];
  });
  for (int i = 0; i < n; ++i) {
    cnt[i] = 1;
  }
  vector<pair<int, int>> ans;
  long long sum = 0;
  for (int i = 0; i < n - 1; ++i) {
    int x = o[i];
    long long v = a[x] - (n - (cnt[x] + 1)) + (cnt[x] - 1);
    if (v >= a[x] || w.count(v) == 0) {
      puts("-1");
      return 0;
    }
    sum += cnt[x];
    int y = w[v];
    ans.emplace_back(x, y);
    cnt[y] += cnt[x];
  }
  if (a[o[n - 1]] != sum) {
    puts("-1");
    return 0;
  }
  for (auto &e : ans) {
    printf("%d %d\n", e.first + 1, e.second + 1);
  }
}


Measured memory_bytes: 10104
#include<bits/stdc++.h>
using namespace std;
int f(long long int x){
	int d=0;
	while(x){
		d++;
		x/=10;
	}return d;
}
int main(){
	long long int x;
	cin >> x;
	int res = 99;
	for(long long int  i=1; i*i<=x; i++)
		if(x%i==0){
			res = min(res, max(f(i),f(x/i)));
		}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<(n);i++)
const int MOD = 1e9 + 7 ;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+3;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   
      int m,k;
      cin>>k>>m;
      if(m==0)
      {
            for(int i=0;i<(1<<k);i++) cout<<i<<" "<<i<<" ";
            return 0;
      }
      if(m>=(1<<k))
      {
            cout<<"-1";
      }
      else{
            vector<int> ans;
            int o=0;
            for(int i=0;i<(1<<k);i++)
            {
                  if(i!=m)
                  {
                        ans.pb(i);
                        o^=i;
                  }
            }
            if(o!=m)
            {
                  cout<<"-1\n";
                  return 0;
            }
            for(auto x:ans) cout<<x<<" ";
            cout<<m<<" ";
            reverse(all(ans));
            for(auto x:ans) cout<<x<<" ";
            cout<<m<<" ";
      }
}     



Measured memory_bytes: 2932
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int numbers = sc.nextInt();
		int[] values = new int[numbers];
		int sum = 0;
		for (int i = 0; i < numbers; i++) {
			values[i] = sc.nextInt();
			sum += values[i];
		}
		
		// finding the average
		int averageCeil = (int) Math.ceil(sum * 1.0/numbers);
		int averageFloor = (int) Math.floor(sum * 1.0/numbers);
		
		// computing the cost
		int totalcostceil = 0; 
		int totalcostfloor = 0;
		for (int i = 0; i < numbers; i++) {
			int ceil = (values[i] - averageCeil) * (values[i] - averageCeil);
			int floor = (values[i] - averageFloor) * (values[i] - averageFloor);
			totalcostceil += ceil;
			totalcostfloor += floor;
		}
		System.out.println(Math.min(totalcostceil, totalcostfloor));
	}
}


Measured memory_bytes: 9556
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextMap()

	if N == len(A) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 10368
#include<iostream>

using namespace std;

int main() {
	int a[3000], b[3000],n=0;
	while(1){
		cin >> a[n] >> b[n];
	if (a[n] == 0 && b[n] == 0)break;
		n++;
	}
	for(int j=0;j<=n;j++){
		if (a[j] == 0 && b[j] == 0)break;
		int cnt = 0;
		if (j != 0)cout << endl;
		for (int i = a[j]; i <= b[j]; i++) {
			
			
			if (i % 4 == 0) {
				if (i % 100 == 0) {
					if (i % 400 == 0) {
						cnt++;
						cout << i << endl;
					}
				}
				else {
					cnt++;
					cout << i << endl;
				}
			}
			if (i == b[j]) {
				if (cnt == 0)cout << "NA" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2996
#include <iostream>
#include <cstdlib>
#include <stack>
using namespace std;

int main(int argc, char const *argv[])
{
    stack<int> S;
    int a, b, x;
    string s;

    while (cin >> s) {
        if (s[0] == '+') {
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a + b);
        } else if (s[0] == '-') {
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a - b);
        } else if (s[0] == '*') {
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a * b);
        } else {
            S.push(atoi(s.c_str()));
        }
    }

    cout << S.top() << endl;

    return 0;
}



Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
int p,n,j,oa;
int a[10000];

int main() {
    // insert code here...
    cin>>n;
    for (int w=0; w<n; w++) {
        cin>>a[w];
    }
    for (int i=0; i<n; i++) {
        
        for (j=i;j>=0&&a[j]<a[j-1]; j--) {
            oa=a[j-1];
            a[j-1]=a[j];
            a[j]=oa;
        }
        for (int z=0; z<n; z++) {
            cout<<a[z];
            if (z!=n-1) {
                cout<<' ';
            }
        }
        cout<<endl;
        
    }
    return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int>kuku(100);
  int tmp=1;
  for(int i=1;i<10;++i){
    for(int j=1;j<10;++j){
	  kuku[tmp]=i*j;
      tmp++;
    }
  }
  for(int k=0;k<101;++k){
    if(kuku[k]==n){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
 
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
 
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define forab(i,a,b) for(int i=a;i<=b;i++)
#define all(x) x.begin(),x.end()
#define trav(i,x) for(auto& i:x)
#define endl cout<<"\n";
//const int mod = 1e9+7;
const int maxn= 2e5+7;
int factors[maxn];
ll mod = 998244353;
int main()
{
    FAST_IO;
    ll n,x,y,k;
    cin>>n>>k;
    int arr[k][2];
    for(int i=0;i<k;i++){
		cin>>arr[i][0]>>arr[i][1];
    }
    vector<ll> dp(maxn,0);
    dp[0]=1;
    dp[1]=-1;
    for(int i=0;i<=n;i++){
		if(i>0)
			dp[i]=(dp[i]+dp[i-1])%mod;
		for(auto it=0;it<k;it++){
			
			int a = arr[it][0];
			int b = arr[it][1];
			
			if(a+i<n)
				dp[i+a]=(dp[i+a]+dp[i])%mod;
			if(b+1+i<n)
				dp[i+b+1]=(dp[i+b+1]-dp[i]+mod)%mod;
		}
    }

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


Measured memory_bytes: 4772
program main
      read(*,*) i, j
      
      if (i.eq.0) then
        write(*,*) "Impossible"
      else if(j.eq.0) then
        write(*,*) "Impossible"
      else
        if (mod(i,3).eq.0) then
          write(*,*) "Possible"
        else if (mod(j,3).eq.0) then
          write(*,*) "Possible"
        else if (mod(i+j,3).eq.0) then
          write(*,*) "Possible"
        else
          write(*,*) "Impossible"
        end if
      end if
      end

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k,x,l,i;
  cin>>n>>k;
  l=0;
  for (i=0;i<n;i++) {
    cin>>x;
    if (2*x<k) l+=2*x;
    else l+=2*(k-x);
  }
  cout<<l<<endl;
}

Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    N = int(input())
    s = set()
    for i in range(N):
        s.add(int(input()))
    
    print(len(s))
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
N,K =map(int,input().split())
R,S,P = map(int,input().split())
T =input()
ans = 0
chk_list = [0] * len(T)
for i in range(len(T)):
    if i < K:
        if T[i] == "r":
            ans += P
        elif T[i] == "s":
            ans += R
        else:
            ans += S
    else:
        if T[i] == T[i-K]:
            if chk_list[i-K] == 0:
                chk_list[i] =1
                continue
        if T[i] == "r":
            ans += P
        elif T[i] == "s":
            ans += R
        elif T[i] == "p":
            ans += S
print(ans)

Measured memory_bytes: 41840
#include <stdio.h>
#define N 100000

int prime[100010];
int cum[100010];
int main(){
	for(int i=2;i*i<N+5;i++)if(!prime[i])for(int j=i+i;j<N+5;j+=i)prime[j]=1;
	for(long long i=2;i<N+5;i++)if(!prime[i]){
		cum[i]=1;
		if(i*i<N+5)cum[i*i]=1;
		if(i*i*i<N+5)cum[i*i*i]=1;
		for(int j=2;i*j<N+5;j++)if(!prime[j])cum[i*j]=1;
	}
	for(int i=2;i<N+5;i++)cum[i]+=cum[i-1];

	int q;
	scanf("%d",&q);
	while(q--){
		int n;
		scanf("%d",&n);
		printf("%d\n",n-1-cum[n]);
	}
}


Measured memory_bytes: 2576
import sys
input = sys.stdin.readline

def is_prime(n: int) -> bool:
    if n <= 3: return n > 1
    elif 0 in [n % 2, n % 3]: return False
    i = 5
    while i * i <= n:
        if 0 in [n % i, n % (i+2)]: return False
        i += 6
    return True

x = int(input())
while not is_prime(x): x += 1
print(x)

Measured memory_bytes: 61800
#include <iostream>

using namespace std;

int main() {
    int area[10001], n, d = 2;
    area[1] = 2;
    for (int i = 2; i <= 10000; i++) {
        area[i] = area[i - 1] + d;
        d++;
    }
    while (cin >> n) {
        cout << area[n] << endl;
    }

    return 0;
}

Measured memory_bytes: 1200
#include <stdio.h>

int main(void)
{
    int n;
    int i,j;
    int count[101] = {0};
    int max;
    int mc[100] = {0};

    /*配列に１～１００を格納*/
    while (scanf("%d", &n) != EOF)
    {
        count[n] += 1;
        //printf("<%d>\n", count[n]);
    }
    
    /*最大値を探す*/
    max = 0;
    for (i = 0; i < 100; i++){
        if (max <= count[i]){
            max = count[i];
        }
    }

    /*最大値と同じ値があるか探す*/
    for (i = 0; i < 100; i++){
        if (max == count[i]){
            printf("%d\n", i);
        }
    }

    return (0);
}


Measured memory_bytes: 2000
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int a[10005],b[10005],n;
ll S = 0;
int main(){
	cin >> n;
	repn(i,n) cin>>a[i],S-=a[i];
	repn(i,n) cin>>b[i],S+=b[i];
	if(S<0){
		puts("No"); return 0;
	}
	ll T = 0;
	repn(i,n){
		ll x = 0;
		if(a[i] < b[i]){
			if((b[i]-a[i])%2 == 0) x = b[i];
			else x = b[i]+1;
		}
		else x = a[i];
		
		T += (x-a[i])/2;
		T -= (x-b[i]);
	}
	if(T<0){
		puts("No");
	}
	else{
		puts("Yes");
	}
}

Measured memory_bytes: 384
A, B, C, X, Y = map(int, input().split())
min1 = 10**18
max1 = max(X, Y)
for i in range(0, max1+1):
    if Y-i<0 and X-i<0:
        cnt = C*2*i
    elif Y-i<0:
        cnt = C*2*i + A*(X-i)
    elif X-i<0:
        cnt = C*2*i + B*(Y-i)
    else:
        cnt = C*2*i + A*(X-i) + B*(Y-i)
    if cnt<min1:
        min1 = cnt
print(min1)

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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int a,b,c;

int main() {
    read(a),read(b),read(c);
    c=min(c,a+b+1);
    write(b+c);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,a;
    cin>>N;
    int b[N];
    for(int i=0;i<N;i++){
        cin>>a;
        b[a-1]=i+1;
    }
    for(int i=0;i<N;i++){
        cout<<b[i]<<" ";
    }
}

Measured memory_bytes: 1152
N = int(input())
a = list(map(int, input().split()))

a.sort()

arrival = 1
ans = 0

while arrival < N:
    score = a.pop()
    if arrival == 1:
        ans += score
        arrival += 1
    else:
        ans += score*min(2, N - arrival)
        arrival += 2

print(ans)

Measured memory_bytes: 31564