akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;


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

	ll H,W,ans=INF;
	cin >> H >> W;
	FOR(i,0,H){
		ll a,b,c;
		a = i*W;
		if(W%2==0||(H-i)%2==0){
			b = W*(H-i)/2;
			c = W*(H-i)/2;
		}else{
			b = min(W,(H-i))*(max(W,(H-i))/2);
			c = min(W,(H-i))*(max(W,(H-i))/2+1);
		}
		ans = min(ans,max({a,b,c})-min({a,b,c}));
	}
	swap(H,W);
	FOR(i,0,H){
		ll a,b,c;
		a = i*W;
		if(W%2==0||(H-i)%2==0){
			b = W*(H-i)/2;
			c = W*(H-i)/2;
		}else{
			b = min(W,(H-i))*(max(W,(H-i))/2);
			c = min(W,(H-i))*(max(W,(H-i))/2+1);
		}
		ans = min(ans,max({a,b,c})-min({a,b,c}));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
struct node{
    int a,b;
    bool operator<(const node & c)const{
        return min(a,b)<min(c.a,c.b);
    }

};
int a[200005];
bool cmp(int a,int b){
    return a>b;
}
int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> a[i];
    sort(a,a+n,cmp);
    priority_queue<node>qq;
    long long ans = 0 ;
    qq.push({a[0],a[0]});
    for(int i=1;i<n;i++){
        int x=qq.top().a;
        int y=qq.top().b;
        qq.pop();
        ans =ans+min(x,y);
        qq.push({a[i],x});
        qq.push({a[i],y});
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6140
N, M = map(int, input().split())
#好きだと答えた人数を格納
fs = [0 for _ in range(M)]
for i in range(N):
    ki = list(map(int, input().split()))
    for n in ki[1:]:
        fs[n-1] += 1

cn = 0
for a in range(M):
    cn += 1 if fs[a] == N else 0
print(cn)


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<string> split_naive(const string &s, char delim) {
	vector<string> elems;
	string item;
	for(char ch:s){
		if(ch==delim){
			if(!item.empty()) elems.push_back(item);
			item.clear();
		}
		else{
			item += ch;
		}
	}
	if(!item.empty()) elems.push_back(item);
	return elems;
}

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

	vector<pair<int,int>> P;
	while(true){
		int p,s;
		scanf("%d,%d",&p,&s);
		if(!p && !s) break;
		P.emplace_back(p,s);
	}

	sort(ALL(P),PAIRCOMP(second,>));
	vector<int> R(P.size());
	int rank=1;
	R[0] = rank;
	for(int i=1,ei=P.size();i<ei;i++){
		if(P[i].second!=P[i-1].second){
			rank++;
		}
		R[i] = rank;
	}
	map<int,int> Q;
	for(int i=0,ei=P.size();i<ei;i++){
		Q.emplace(P[i].first,R[i]);
	}

	int N;
	while(cin>>N){
		out(Q[N]);
	}
	
	return 0;
}


Measured memory_bytes: 3204
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> L(K),R(K);
  int i,j;
  for(i=0;i<N;i++)cin >> L[i] >> R[i];
  vector<long long> w(N+1,0),s(N+2);
  s[N+1] = 0;
  w[N] = s[N] = 1;
  for(i=0;i<N;i++) {
    for(j=0;j<K;j++) {
      if(L[j]-i-1 <= 0)w[N-i-1] = (w[N-i-1] + s[N-i-1+L[j]]-s[min(N+1,N-i+R[j])] + 998244353)%998244353;
    }
    s[N-i-1] = (s[N-i]+w[N-i-1])%998244353;
  }
  cout << w[1] << endl;
}

Measured memory_bytes: 6372
import numpy as np

NKQ=np.array(input().split(),dtype=np.int32)

N=NKQ[0]
K=NKQ[1]
Q=NKQ[2]

score=[K]*N
score=np.array(score,dtype=np.int32)

A=[]
for i in range(Q):
    A.append(int(input())-1)

A=np.sort(A)

score=score-Q

for i in A:
    score[i]+=1
    

for i in range(N):
    if(score[i]<=0):
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 17876
#include<bits/stdc++.h>
using namespace std;
int main(){
  bitset<1000000> bit;
  vector<int> prime;
  bit.set();
  for (int i = 2; i <= 1000000;i++){
    if(bit[i]==1){
      prime.push_back(i);
      for (int j = i * 2; j <= 1000000;j+=i){
        bit[j] = 0;
      }
    }
  }

  while(1){
    int n, p;
    cin >> n >> p;
    if(n==-1&&p==-1){
      break;
    }
    vector<int> sum;
    int index = 0;
    while(prime[index]<=n){
      index++;
    }
    for (int i = index; i - index < p;i++){
      for (int j = i; j - index < p;j++){
        sum.push_back(prime[i] + prime[j]);
      }
    }
    sort(sum.begin(), sum.end());
    cout << sum[p - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const int maxn=(2e5)+10;
int x,y,a,b,c;
ll s1[maxn],s2[maxn],s3[maxn],ans;
ll t1,t2,tmp,d[maxn],S3[maxn];
struct cmp {
	bool operator() (ll a,ll b) {
		return a>b;
	} 
};
priority_queue<ll,vector<ll>,cmp> q;
int main() {
	//freopen("1.txt","r",stdin);
	read(x); read(y); read(a); read(b); read(c);
	for (int i=1;i<=a;i++) read(s1[i]);
	sort(s1+1,s1+a+1); reverse(s1+1,s1+a+1);
	for (int i=1;i<=a;i++) s1[i]+=s1[i-1];
	
	for (int i=1;i<=b;i++) read(s2[i]);
	sort(s2+1,s2+b+1); reverse(s2+1,s2+b+1);
	for (int i=1;i<=b;i++) d[i]=s2[i],s2[i]+=s2[i-1];
	
	for (int i=1;i<=c;i++) read(s3[i]);
	sort(s3+1,s3+c+1); reverse(s3+1,s3+c+1);
	
	for (int i=1;i<=c;i++) S3[i]=S3[i-1]+s3[i];
	ll sum=0;
	for (int j=x-max(0,x-c)+1;j<=c;j++) q.push(s3[j]),sum+=s3[j];	
	for (int j=1;j<=b;j++) q.push(d[j]),sum+=d[j];
	while (q.size()>y) sum-=q.top(),q.pop();
	
	for (int i=max(0,x-c);i<=x;i++) {
		ans=max(ans,s1[i]+sum+S3[x-i]);
		if (i==x) break;
		q.push(s3[x-i]),sum+=s3[x-i];
		sum-=q.top(); q.pop();
	}
	
	printf("%lld\n",ans);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

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

const int inf = 1e9;
const ll linf = 1e18;

int dsum(int n)
{
    int res = 0;
    while(n) {
        res += n % 10;
        n /= 10;
    }
    return res;
}

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

    int n, a, b; cin >> n >> a >> b;
    
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int d = dsum(i);
        if (a <= d && d <= b) ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;


int main() {
	string str;
	cin >> str;
	int cnt = 0;
	FOR (i, str.sz)
		if (!i || str[i] != str[i - 1])
			cnt++;
	cout << cnt - 1 << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

int main() {
    int n,T;
    cin >> n >> T;
    vector<int>t(n);
    rep(i,n) cin >> t[i];
    int ans = 0;
    rep(i,n-1) {
        int x = t[i+1] - t[i];
        ans += min(T,x);
    }
    ans += T;
    cout << ans << endl;
}

Measured memory_bytes: 3952
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
using namespace std;

#define N 200002

vector<int >edge[N];

char s[N];
int vis[N][4];
char t[4] ={'A','A','B','B'};
bool dfs(int node,int ord) {
  if(vis[node][ord]==1) {
    return true;
  }
  vis[node][ord] = 1;
  char tt = t[(ord+1)%4];
  for(int i=0;i<edge[node].size();++i) {
    int ch = edge[node][i];
    char g = s[ch];
    if(tt==g) {
      if(dfs(ch,(ord+1)%4)) {
        return true;
      }
    }
  }
  vis[node][ord] = 2;
  return false;
}
void solve() {
  int n,m;scanf("%d %d",&n,&m);
  scanf(" %s",s+1);
  for(int i=m;i;--i) {
    int a,b;scanf("%d %d",&a,&b);
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  for(int i=1;i<=n;++i) {
    if(!vis[i][0] && s[i]=='A') {
      if(dfs(i,0)) {
        printf("Yes\n" );
        return;
      }
    }
  }
  printf("No\n");
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


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

int main() {
  ll a,b,c,result;
  cin >> a >> b >> c;
  if(a%2 == 0 || b%2 == 0 || c%2 == 0) 
    result = 0;
  else{
    result = min(b*c,a*c);
    result = min(result,a*b);
  }
  cout <<result;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

	int n, x;
	vector<int> v;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> x;
		v.push_back(x);
	}
	int max = *std::max_element(v.begin(), v.end());
	int min = *std::min_element(v.begin(), v.end());

	cout << max - min << endl;
	return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

#define MAX 50

int n,a;
int x[MAX];
ll dp[51][51][2501];

ll DFS(int depth, int use, ll sum){
    if(dp[depth][use][sum] != -1){
        return dp[depth][use][sum];
    }
    if(depth >= n){
        if(use != 0 && sum == use * a){
            return 1;
        }else{
            return 0;
        }
    }
    return dp[depth][use][sum] = DFS(depth + 1, use + 1, sum + x[depth]) + DFS(depth + 1, use, sum);
}

signed main(){
    cin >> n >> a;
    REP(i,n){
        cin >> x[i];
    }
    memset(dp, -1, sizeof(dp));
    ll ans = DFS(0, 0, 0);
    cout << ans << endl;
}

Measured memory_bytes: 51072
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int x;
    cin >> x;
    int ans = 1;
    for(int i = 2; i*i <= x; i++) {
        int ni = i*i;
        while(ni <= x) {
            ni *= i;
        }
        ans = max(ans,ni/i);
    }
    cout << ans << endl;
}

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

int main() {
  	int N;
  	cin>>N;
  
	string S;
  	for(int i=0;i<N;i++){
    	cin>>S[i];
    }
  	int cotae=0;
  	  
  	for(int j=0;j<N;j++){
      if('A'==S[j]&&'B'==S[j+1]&&'C'==S[j+2]){
      	cotae++;
      }
    }
      
      cout<<cotae<<endl;
      
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
int n;
std::string s;

int main()
{
    std::cin >> s;
    n = s.size();
    long long ans = 0;

    for(int bit = 0; bit < (1 << (n - 1)); bit++){
        long long num = 0;
        std::string cur;
        for(int i = 0; i < n; i++){
            cur.push_back(s[i]);
            if(bit & (1 << i)){
                num += std::stol(cur);
                cur = {};
            }
        }
        if(cur.size() != 0)num += std::stol(cur);
        ans += num;
//        std::cout << num << std::endl;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define X first
#define Y second
using namespace std;

int main(){
	string key[] = {"egg", "chicken"};
	vector<vector<string> > combi(1000);
	pair<int, int> currentpos(0, 0); 
	string input;
	cin >> input;
	for(int i = 0; i < input.size();){
		int index;
		if(input[i]==key[0][0]){
			index = 0;
			i += key[0].size();
		}
		else if(input[i]==key[1][0]){
			index = 1;
			i += key[1].size();
		}
		if(currentpos.Y){
			if(combi[currentpos.X][currentpos.Y-1] == key[index]){
				currentpos.X++;
				currentpos.Y = 0;
			}
			combi[currentpos.X].push_back(key[index]);
		}
		else combi[currentpos.X].push_back(key[index]);
		currentpos.Y++;
	}
	int maxX = 0, maxY = 0;
	for(int i = 0; i < combi.size(); i++){
		if(maxY < combi[i].size()){
			maxX = i;
			maxY = combi[i].size();
		}
	}

	cout << combi[maxX][maxY-1] << endl;
	return 0;
}

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

int main() {
  int a, b;
  string str_a = "", str_b = "";
  cin >> a >> b;
  for(int i = 0; i < b; i++){
  	str_a += to_string(a);
  }
  for(int i = 0; i < a; i++){
  	str_b += to_string(b);
  }
  if(a == b){
  	cout << str_a << endl;
    return 0;
  }else if(a < b) {
  	cout << str_a << endl;
    return 0;
  }else {
  	cout << str_b << endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 256
a,b,c = [input() for i in range(3)]
turn = 'a'
while True:
    if turn == 'a':
        if len(a) == 0:
            break
        turn = a[0]
        a = a[1:]
    elif turn == 'b':
        if len(b) == 0:
            break
        turn = b[0]
        b = b[1:]
    elif turn == 'c':
        if len(c) == 0:
            break
        turn = c[0]
        c = c[1:]
        
print(turn.upper())

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

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
main() {
    string s, t;
    cin >> s >> t;
    cout << (s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2]);
}


Measured memory_bytes: 256
/*input
58 23 42
*/

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

#define Fi              first
#define Se              second
#define S(n)            cin >> n
#define P(n)            cout << n
#define pb              push_back
#define pp              pop_back
#define pf              pop_front
#define sp              cout << " "
#define nl              cout << "\n"
#define MIN(con)        (*min_element(ALL(con))) 
#define MAX(con)        (*max_element(ALL(con)))
#define mem(n, a)       memset((n), (a), sizeof(n))
#define ALL(cont)       (cont).begin(),(cont).end()
#define NX(cont)        next_permutation(ALL(cont))
#define PX(cont)        prev_permutation(ALL(cont))
#define F(i, n, r)      for(int i = (n); i < (r); i ++)
#define prec(n)         cout << fixed << setprecision(n)
#define PI              3.14159265358979323846264338327951
#define fast            ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define FH(it,c)   for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++ it)
 
using ll = long long;
using ss = stringstream;
using ul = unsigned long long;
 
template < typename T > inline T LCM(T a, T b)            { return (a * b) / GCD(a, b); }
template < typename T > inline T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > inline T _max(T a, T b, T c)      { return max( max( a, b ), c ); }
template < typename T > inline T _min(T a, T b, T c)      { return min( min( a, b ), c ); }
template < typename T > inline string toString(T a)       {return to_string(a); }  // Convert int to string
template < typename T > inline void toInt(string s, T &x) { ss str(s); str >> x;}  // Convert string to int

inline void lower(string &s) { 
  FH(it,s) 
    *it = tolower(*it); 
} 
 
inline void upper(string &s) { 
  FH(it,s) 
    *it = toupper(*it); 
}

const ll inf    =  999999999999999999;

bool palin(string s)
{
    string s1 = s;
    reverse(s.begin(), s.end());
    return (s == s1);
} 

ll triangle(ll n)
{
    return (n * (n + 1)) / 2;
}

bool check(ll n) 
{
    if(n == 1) return 0;
    if(n == 2 or n == 3) return 1;
    if(n % 2 == 0 or n % 3 == 0) return 0;

    for(ll i = 5; i * i <= n; i += 6) if(n % i == 0 or n % (i + 2) == 0) return 0;
    return 1;
}

int main ()
{
    fast;
    int n, a, b;
    cin >> n >> a >> b;
    while(1) {
        if(a + 1 == b) {
            cout << "Borys";
            return 0;
        }
        else {
            a ++;
        }
        if(b - 1 == a) {
            cout << "Alice";
            return 0;
        }
        else {
            b --;
        }
    }
    nl;
    return 0;
}



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

int main() {
  int x;cin>>x;
  while(1){
    int t=x;
    bool ans=true;
    for(int i=2;i<x;i++){
      if(t%i==0)ans=false;
    }
    if(ans){
      cout<<t<<endl;
      return 0;
    }
    x++;
  }
}

Measured memory_bytes: 3588
# 選択ソート

def selectSort(array)
  count = 0
  (array.length - 1).times do |i|
    p array if $debug
    min_index = i + array[i..-1].index(array[i..-1].min)
    if min_index != i
      not_min, min = array[i], array[min_index]
      array[i], array[min_index] = min, not_min
      count += 1
    end
    i += 1
  end
  [count, array]
end

$debug = false
_n = gets.to_i
array = gets.split.map(&:to_i)
count, array = selectSort(array)
puts array.join(" ")
puts count



Measured memory_bytes: 6916
a=[]
ans=[]

for i in range(0,28):
    n=int(input())
    a.append(n)
list.sort(a)
if a[0]==2:ans.append(1)
if a[0]==3:ans.append(1,2)
if a[27]==29:ans.append(30)
if a[27]==28:ans.append(29,30)
        
for i in range(0,27):
    b=a[i+1]-a[i]
    if b==2:ans.append(a[i]+1)
    elif b==3:ans.append(a[i]+1,a[i]+2)
        
print(ans[0])
print(ans[1])


Measured memory_bytes: 5600
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, int> LP;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll k;
	cin >> n >> k;
	vector<ll> a(n), b(n);
	rep(i,n) cin >> a[i] >> b[i];
	ll two = 1, ans = 0, score = 0;
	int r = 0;
	rep(i,n){
		bool ok = true;
		rep(j,32){
			if(a[i]>>j & 1){
				if(!(k>>j & 1)) ok = false;
			}
		}
		if(ok) score += b[i];
	}
	chmax(ans, score);
	while(two <= k){
		ll ki = k;
		if(ki>>r & 1){
			ki /= two;
			ki *= two;
			ki -= 1;
		}
		//cout << r << " " << two << " " << ki << endl;
		score = 0;
		rep(i,n){
			bool ok = true;
			rep(j,32){
				if(a[i]>>j & 1){
					if(!(ki>>j & 1)) ok = false;
				}
			}
			if(ok) score += b[i];
		}
		chmax(ans, score);
		++r;
		two *= 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4728
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	string s;
	cin>>s;
	int a=0,b=0,c=0;
	for (int i=0;i<s.size();i++){
		switch(s[i]){
			case 'a':
				a++;
				break;
			case 'b':
				b++;
				break;
			case 'c':
				c++;
				break;
		}
	}
	if (a==1 &&b==1&&c==1){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ncr(int n,int r){if(n<r)return 0;int p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;int g=__gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}
#define pi acos(-1)
int ar[N];
int tree[2*N];
int dp[N];
int bit[N];
signed main(){
 	// #ifndef ONLINE_JUDGE
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		int n;
		cin >> n;
		map<int,int>mp;
		fn{
			cin >> ar[i];
			ar[i]--;
		}
		vector<int>v(n,0);
		for(int i=0;i<n;i++)v[ar[i]]=i+1;
		for(auto i :v)cout<<i<<" " ;

	
	}
	
	return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main (){
    int N;
    int H = 0;
    int L = 0;
    int nH = 0;
    int nL = 0;
    cin >> N;
    vector<int> in;
    for(int i = 0;i < N;i++){
        int temp;
        cin >> temp;
        in.push_back(temp);
        if(H == 0 || temp == H){
            H = temp;
            nH++;
        }else if (temp == H - 1){
            L = temp;
            nL++;
        }else if (temp == H + 1 && L == 0){
            L = H;
            H = temp;
            nL = nH;
            nH = 1;
        }else{
            cout << "No" << endl;
            return 0;
        }
    }
    if(nL > L){
            cout << "No" << endl;
            return 0;
    }else if(nH / 2 < L - nL+1){
        cout << "No" << endl;
            return 0;
    }else if(L == 0){
        if(H == 1 || H == N-1){
           cout << "Yes" << endl;
            return 0;
        }else if(H > N/2) {
            cout << "No" << endl;
            return 0;
            
        }
    }
           cout << "Yes" << endl;
            return 0;
    
}

Measured memory_bytes: 892
/*
    a
*/
#include <bits/stdc++.h>

namespace Lsk {
#define _auto_ template <typename T>

// fast io
#define writesp(x) (write(x), putchar(' '))
#define writeln(x) (write(x), putchar('\n'))
_auto_ inline void read(T &x) {
	x = 0; bool sgn = false; char ch = getchar();
	while(!isdigit(ch)) (ch == '-') && (sgn = true), ch = getchar();
	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	if(sgn) x = -x;
}
_auto_ inline void write(T x) {
	if(x < 0) putchar('-'), x = -x;
	static char buf[40]; int o = 0;
	for(x; x > 9; x /= 10, ++o) buf[o] = x % 10 + '0'; buf[o] = x + '0';
	for(o; ~o; --o) putchar(buf[o]);
	return;
}

// cmin / cmax / swap
_auto_ inline void cmin(T &u, const T v) { if(u > v) u = v; }
_auto_ inline void cmax(T &u, const T v) { if(u < v) u = v; }
_auto_ inline T min(const T u, const T v) { return u < v ? u : v; }
_auto_ inline T max(const T u, const T v) { return u > v ? u : v; }
_auto_ inline void swap(T &u, T &v) { T tmp(u); u = v, v = tmp; }

// math
const int mod = 998244353, mod_2 = 1996488706;
//const int mod = 1000000007, mod_2 = 2000000014;
//const int mod = 1000000009, mod_2 = 2000000018;
_auto_ inline T abs(T x) { return x > 0 ? x : -x; }
_auto_ inline T gcd(T u, T v) {	return v ? gcd(v, u % v) : u; }
_auto_ inline T Mod(T u) { return u >= mod_2 ? u % mod : (u > mod ? u - mod : u); }
_auto_ inline T inmod(T u) { return u >= mod ? u - mod : (u < 0 ? u + mod : u); }
inline long long fpm(long long base, long long mi) {
	long long res = 1;
	while(mi) {
		if(mi & 1) res = Mod(res * base);
		base = Mod(base * base), mi >>= 1;
	}
	return res;
}

} using namespace Lsk;

int A, B;


int main() {
	read(A), read(B);
	if(A > 9 || B > 9) {
		puts("-1");
		return 0;
	}
	writeln(A * B);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long

const int N=100005;
const int MOD=1e9+7;
 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
vector<int> v;
set<int> s; 
 
 void dfs(int n)
 {
	 if(n>4e9)
	 return ;
	 s.insert(n);
     int last=n%10;
     if(last-1>=0)
     dfs(n*10+last-1);
     
      dfs(n*10+last);
      
      if(last+1<=9)
      dfs(n*10+last+1);
     	 
}
int32_t main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/


for(int i=1;i<=9;i++)
{
	dfs(i);
}

for(auto &it:s)
{
	v.push_back(it);
}

int k;
cin>>k;
cout<<v[k-1]<<endl;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
//const ll INF = 1LL<<60;
int INF = numeric_limits<int>::max();

int main(int, char**) {
	string s, t; cin >> s >> t;
	vector<vector<int>> M(26, vector<int>(0));
	for (int i=0; i<s.size(); i++) {
		int c = s[i] - 'a';
		M[c].push_back(i);
	}
	ll cnt = 0;
	int now = INF;
	for (int i=0; i<t.size(); i++) {
		int c = t[i] - 'a';
		if (M[c].size()==0) {
			cout << -1 << endl;
			return 0;
		}
		auto itr = upper_bound(M[c].begin(), M[c].end(), now);
		if (itr==M[c].end()) {
			cnt++;
			now = M[c][0];
		} else {
			now = *itr;
		}
	}
	ll ret = (cnt - 1) * s.size() + now + 1;
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 1216
# include <bits/stdc++.h>
using namespace std; 
const int mod=1e9+7;
int main(){
 long long int n, k,i,j,p;
  cin>>n>>k; 
  long long int ar[n];
  for(i=0;i<n;i++){
    cin>>ar[i];
  }
long long int dp[n];
  memset(dp,mod,sizeof(dp));
  dp[0]=0;
  for(i=0;i<n; i++){
    for(j=i+1;j<=i+k;j++){
      if(j<n)
    dp[j]=min(dp[j],(abs(ar[j]-ar[i])+dp[i]));
    }
  }
 /* for(i=0;i<n; i++){
    cout<<dp[i]<<" ";
  }*/
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 5096
import numpy as np
a,b,k=map(int,input().split())
n=list(map(int,input().split()))
m=list(map(int,input().split()))
n.insert(0,0)
m.insert(0,0)
n=np.array(n)
m=np.array(m)
n=n.cumsum()
m=m.cumsum()
ans=0
j=len(m)-1
for i in range(len(n)):
    if n[i]>k:
        break
    while m[j]>k-n[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)

Measured memory_bytes: 58428
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
			int N = cin.ReadInt;
          	int[] intArray = new int[N];
          	for (int i = 0; i < N; i++)
            {
              intArray[i] = cin.ReadInt;
            }
          Array.Sort(intArray);
          decimal sum = 0;
          for (int j = 0; j < intArray.Length; j++)
          {
            if (j == 0)
            { 
              sum += intArray[j]; 
            }          
            else           
            { 
              sum = (sum + intArray[j]) / 2;
            }
          }
          WriteLine(Decimal.Round(sum, 5, MidpointRounding.AwayFromZero));
        }
    }
    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public decimal ReadDecimal { get { return decimal.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


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

int main()
{
	ll a,b,c;
	cin >> a >> b >> c;
	ll d = c-a-b;
	if (d <= 0)
	{
		cout << "No" << endl;
	}
	else
	{
		if (4 * a * b < d*d)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
using namespace std;


int main() {
	long long int deskA, deskB, totalTime;
	cin >> deskA >> deskB >> totalTime;
	vector <long long int> timeA(deskA);
	vector <long long int> timeB(deskB);
	vector <long long int> prefixSumA(deskA + 1);
	vector <long long int> prefixSumB(deskB + 1);
	prefixSumA.push_back(0);
	prefixSumB.push_back(0);
	for (long long int i = 0; i < deskA; i++) {
		cin >> timeA[i];
		prefixSumA[i+1] = prefixSumA[i] + timeA[i];
	}
	for (long long int j = 0; j < deskB; j++) {
		cin >> timeB[j];
		prefixSumB[j+1] = prefixSumB[j] + timeB[j];
	}
	long long int maxBooks;;
	vector <long long int> result;
	long long int m = timeB.size();
	for (long long int i = 0; i < timeA.size()+1; i++) {
		long long int remainingTime = totalTime - prefixSumA[i];
		for (long long int j = m ; j >= 0; j--) {
			if (prefixSumA[i] + prefixSumB[j] <= totalTime) {
				m = j;
				result.push_back(i + j);
				break;
			}
		}
	}
	maxBooks = *max_element(result.begin(), result.end());
	cout << maxBooks;
	return 0;
}

Measured memory_bytes: 12992
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)
//std::sort(v.begin(), v.end(), std::greater<Type>());
//set_intersection(x, x+7, y, y+6, back_inserter(v));
//set_union(x, x+7, y, y+6, back_inserter(v));
//set_difference(x, x+7, y, y+6, back_inserter(v));

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}


int N;
int ans = 0;

int count(int a){
  int cnt = 0;
  while(a%2==0){
    cnt++;
    a/=2;
  }
  return cnt;
}

int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    int a; cin >> a;
    ans += count(a);
  }
  cout<< ans <<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string jz(int n)
{
	string s="1";
	for(;n;)
	{
		s+=(char)(n%2+'0');
		n/=2;
	}
	return s;
}
int main()
{
	string s;
	cin>>s;
	long long ans=0;
	int x=1;
	for(int i=0;i<s.size()-1;i++)
	{
	  x*=2;	
	}
	//cout<<x<<endl;
	for(int i=0;i<x;i++)
	{
		string z=jz(i);
	    for(int j=z.size()-1;j<s.size()-1;j++)
	    {
		  z+='0';
	    }
		reverse(z.begin(),z.end());
		//cout<<z<<" ";
		int last=0;
		for(int j=0;j<s.size();j++)
		{
			if(z[j]=='1')
			{
				long long m=0;
				for(int k=last;k<=j;k++)
				{
					m=m*10+(int)(s[k]-'0');
				}
				ans+=m;
				//cout<<m<<" ";
				last=j+1;
			}
		}
		//cout<<endl;
	}
	//cout<<endl;
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
constexpr long long int mod = 1000000007;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int>p(N);
    for (size_t i = 0; i < K; i++)
    {
        int d;
        cin >> d;
        for (size_t j = 0; j < d; j++)
        {
            int e;
            cin >> e;
            e--;
            p.at(e)++;
        }
    }
    int ans=0;
    for (size_t i = 0; i < N; i++)
    {
        if (p.at(i) == 0)ans++;
    }
    cout << ans;
}

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

const int mod = 1000000007;

int main()
{
	string S;
	int dp[100005][4] = {};

	cin >> S;

	dp[0][0] = 1;	
	for ( int i = 0; i < S.size(); i++ ) {
		for ( int j = 0; j < 4; j++ ) {
			(dp[i + 1][j] += dp[i][j]) %= mod;
		}
		if ( S[i] == '?' ) {
			for ( int j = 0; j < 4; j++ ) {
				(dp[i + 1][j] += (dp[i][j] * 2) % mod) %= mod;
				if ( j < 3 ) {
					(dp[i + 1][j + 1] += dp[i][j]) %= mod;
				}
			}
		} else {
			(dp[i + 1][S[i] - 'A' + 1] += dp[i][S[i] - 'A']) %= mod;
		}
	}
	cout << dp[S.size()][3] << endl;
	return ( 0 );
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;
    C *= 2;
    int ret = min(A * X + B * Y,C * max(X,Y));
    if(X > Y) {
        ret = min(ret,Y * C + A * (X - Y));
    }
    else {
        ret = min(ret,X * C + B * (Y - X));
    }
    cout << ret << endl;
}

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

int main(){
    int n;
    while( cin >> n ){
        vector<int>v;
        for( int i = 1; i <= n; i++ ){
            v.push_back(i);
        }
        vector<int> v1, v2;
        for( int i = 0; i < n; i++ ){
            int a; cin >> a;
            v1.push_back(a);
        }
        for( int i = 0; i < n; i++ ){
            int a; cin >> a;
            v2.push_back(a);
        }
        int l = 0, m = 0;
        int cnt = 0;
        do{
            cnt++;
            if( v == v1 ){
                l = cnt;
            }
            if( v == v2 ){
                m = cnt;
            }
        }while( next_permutation( v.begin(), v.end() ) );
        cout << abs( l-m ) << "\n";
    }
}
/*
7 2
0 1 0 0 0 1 0
*/


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

int main(){
 int a,b,c;
 int d=0;

 cin >>a;
 for (b = 1; b < 10; b++) {
   for (c = 1; c < 10; c++) {
     if(a==b*c){
       d +=1;
     }
   }
 }

if(d>=1){
  cout << "Yes" <<endl;
}
else{
  cout <<"No" <<endl;
}

}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;
	int[][] map;
	String rp = ".OPYBGR";
	int w = 6, h = 12;

	void run() {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		for(;t>0;t--) {
			map = new int[h+2][w+2];
			for(int i=1;i<=12;i++) {
				String s = sc.next();
				for(int j=0;j<rp.length();j++) s = s.replace(rp.charAt(j), (char)('0' + j));
				for(int j=1;j<=6;j++) map[i][j] = s.charAt(j-1) - '0';
			}
			boolean ch = true;
			int c = 0;
//			for(int[] a: map) debug(a);
			for(;;c++) {
				ch = false;
				for(int i=1;i<=w;i++) for(int j=1;j<=h;j++) if(map[j][i] > 1) {
					int cnt = dfs(i, j, map[j][i]);
					if(cnt >= 4) { del(i, j, map[j][i]); ch = true; }
//					for(int[] a: map) debug(a);
				}
				if(!ch) break;
				down();
//				for(int[] a: map) debug(a);

			}
			System.out.println(c);
		}
	}

	int dx[] = {-1,0,1,0}, dy[] = {0,-1,0,1};
	int dfs(int x, int y, int c) {
//		debug(x, y);
		map[y][x] = 0;
		int cnt = 1;
		for(int i=0;i<4;i++) if(map[y+dy[i]][x+dx[i]] == c) cnt += dfs(x+dx[i], y+dy[i], c);
		map[y][x] = c;
		return cnt;
	}

	void del(int x, int y, int c) {
		map[y][x] = 0;
		for(int i=0;i<4;i++) {
			if(map[y+dy[i]][x+dx[i]] == c) del(x+dx[i], y+dy[i], c);
			if(map[y+dy[i]][x+dx[i]] == 1) map[y+dy[i]][x+dx[i]] = 0;
		}
	}

	void down() {
		for(int j=1;j<=w;j++){
			for(int k=0;k<=h+2;k++) for(int i=0;i<=h-1;i++)
				if(map[i+1][j] == 0) { map[i+1][j] = map[i][j]; map[i][j] = 0;}
		}
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 21448
#include <iostream>
using namespace std;
int main()
{
  int n,m,p,i,s,a[100];
  for(;;){
    cin >> n >> m >> p;
    if(n==0 && m==0 && p==0) break;
    s = 0;
    for(i=0;i<n;i++){
      cin >> a[i];
      s += a[i];
    }
    if(a[m-1] == 0) cout << "0" << endl;
    else{
      s = s * (100 - p);
      cout << s / a[m-1] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
using System;
using CompLib.Util;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        long a = sc.NextLong();
        long b = sc.NextLong();
        long n = sc.NextLong();

        long x = Math.Min(b - 1, n);

        var l = (a * x) / b;
        var r = a * (x / b);

        Console.WriteLine(l - r);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

int main()
{
  vector <int> a(26);
  string s;
  cin>>s;
  for(auto i:s) a[i-'a']++;
  for(int i=0;i<26;i++)
    if(a[i]==0)
      {cout<<(char)('a'+ i)<<"\n";return 0;}
  cout<<"None\n";


  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    ll n,a[5];
    cin >> n;
    rep(i,5)cin >> a[i];
    sort(a,a+5);
    if(a[0]>=n)cout << 5 << endl;
    else{
        if(n%a[0]!=0){
            cout << n/a[0]+5LL << endl;
        }else{
            cout << n/a[0]+4LL << endl;
        } 
    } 
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll x2 = 0;
  rep(i, n) if(i % 2) x2 -= a[i];
  else x2 += a[i];
  vector<int> ans(n);
  ans[0] = x2 / 2;
  rep(i, n - 1) ans[i + 1] = a[i] - ans[i];
  rep(i, n) ans[i] *= 2;
  rep(i, n) printf("%d%c", ans[i], i == n - 1 ? '\n' : ' ');
  return 0;
}

Measured memory_bytes: 2048
N = int(input())
D = list(map(int,input().split()))
if D[0] != 0:
    print(0)
    exit()
from collections import Counter
ctr = Counter(D)
if ctr[0] > 1:
    print(0)
    exit()

MOD = 998244353
ans = 1
for i in range(len(ctr)-1):
    ans *= pow(ctr[i], ctr[i+1], MOD)
    ans %= MOD
print(ans)

Measured memory_bytes: 24012
#include<bits/stdc++.h>
#define ll long long
#define N 300005
#define M 1000000007
#define pii pair<ll,ll>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
main()
{
    string s;
    cin>>s;
    for(auto &c:s)
    {
        if(c=='?')
            c='D';
    }
    cout<<s;
}



Measured memory_bytes: 3728
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		for (int k = 0; k < n; k++) {
			if (k != n - 1) {
				System.out.print(a[k]);
				System.out.print(" ");
			} else {
				System.out.println(a[k]);
			}
		}
		insertionSort(n, a);
	}

	public static void insertionSort(int n, int[] a) {
		int j, v;
		for (int i = 1; i < n; i++) {
			v = a[i];
			j = i - 1;
			while (j >= 0 && a[j] > v) {
				a[j + 1] = a[j];
				j--;
			}
			a[j + 1] = v;
			for (int k = 0; k < n; k++) {
				if (k != n - 1) {
					System.out.print(a[k]);
					System.out.print(" ");
				} else {
					System.out.println(a[k]);
				}
			}
		}
	}
}



Measured memory_bytes: 33896
#include <iostream>
#include <vector>

int main() {

    // The frog jumps from stone `i` to either stone `i+1` or `i+2`. The cost of doing so is
    // equal to the difference in heights of the two stones, |h[j] - h[i]| when jumping to
    // stone `j` from stone `i`.
    //
    // Consider any generic stone `i` that the frog is on. Let DP[i] equal the minimum possible
    // cost of jumping to stone `i`. So the cost of jumping from stone `i-2` must be equal to
    // `DP[i-2] + abs(h[i]-h[i-2])`, and likewise with i-1: `DP[i-1] + abs(h[i]-h[i-2])`. So the
    // cost to get to stone `i` must be the minimum of those two!

    int n;
    std::cin >> n;
    std::vector<int> heights(n);
    for (int i = 0; i < n; i++) {
        std::cin >> heights[i];
    }

    std::vector<int> dp(n);
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        int minval = 2e9;
        for (int k = 1; k <= 2; k++) {
            if (i-k < 0) {
                continue;
            }
            minval = std::min(minval, dp[i-k] + std::abs(heights[i]-heights[i-k]));
        }

        dp[i] = minval;
    }

    std::cout << dp[n-1];


    return 0;
}


Measured memory_bytes: 1024
N, K=map(int, input().split())
p=list(map(int, input().split()))

M=[sum(p[:K])]
for i in range(1,N-K+1):
  tmp=M[-1]-p[i-1]+p[i+K-1]
  M.append(tmp)

ans=max(M)/2+K/2
print(ans)

Measured memory_bytes: 25060
import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }
        double[] ev = new double[n];
        for (int i = 0; i < n; i++) {
            ev[i] = (double) (1 + p[i]) / 2;
        }
        double[] sum = new double[n + 1];
        for (int i = 1; i <= n; i++) {
            sum[i] = sum[i - 1] + ev[i - 1];
        }
        double ans = 0;
        for (int i = 0; i + k <= n; i++) {
            ans = Math.max(ans, sum[i + k] - sum[i]);
        }
        System.out.println(ans);
    }
}

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector <vector <int> > a(n, vector <int> (3));
  vector <vector <int> > dp(n, vector <int> (3));
  for (int i = 0; i < n; ++i)
    scanf("%d %d %d", &a[i][0], &a[i][1], &a[i][2]);
  dp[0][0] = a[0][0];
  dp[0][1] = a[0][1];
  dp[0][2] = a[0][2];
  for (int i = 1; i < n; ++i) {
    dp[i][0] = max(dp[i - 1][1] + a[i][0], dp[i - 1][2] + a[i][0]);
    dp[i][1] = max(dp[i - 1][0] + a[i][1], dp[i - 1][2] + a[i][1]);
    dp[i][2] = max(dp[i - 1][0] + a[i][2], dp[i - 1][1] + a[i][2]);
  }
  printf("%d", max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])));
  return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;

int main()
{
	int n, i;
	while (1){
		cin >> n;
		int a[35] = {};
		if (n == 0) break;
		a[0] = 0;
		a[1] = 0;
		a[2] = 1;
		for (i = 0; i < n; i++){
			a[i + 3] = a[i + 2] + a[i + 1] + a[i];
		}
		cout << a[n + 2]/3650+1 << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <bitset>

using namespace std;

#define UNION true
#define NEIGHBOR true

struct Union{
	string A;
	unsigned short B,C;
	int D[42];
	queue<string> S;
} 	U[42];

struct UnionSearch{
	bitset<41> State;
	unsigned short B;
};

void AddUnion(UnionSearch *us, int u){
	us->State[u] = UNION;
	for(int i=0;i<U[u].C;i++) us->State.set( U[u].D[i] );
	us->B += U[u].B;
}

int N;
queue <UnionSearch> US;


int Find(string s){
	for(int i=1;i<=N;i++) if(s==U[i].A) return i;
	printf("error");
	return 0;
}

main(){
	int i,c;
	unsigned short Max;
	string s;
	UnionSearch q, p;
	while(cin>>N,N){
	//	US.clear();
		while(!US.empty()) US.pop();
		for(i=0;i<42;i++){
			U[i].A = "";
			U[i].B=0;
			U[i].C=0;
			memset(U[i].D, 0, 42*sizeof(int));
			while(!U[i].S.empty()) U[i].S.pop();
		}
		Max = 0;
		q.B=0;
		q.State.reset();
		
		for(i=1;i<=N;i++){
			cin>>U[i].A>>U[i].B>>c;
			while(c--){
				cin>>s;
				U[i].S.push(s);
			}
		}

		for(i=1;i<=N;i++){
			while(!U[i].S.empty()){
				U[i].D[U[i].C++] = Find(U[i].S.front());
				U[i].S.pop();
			}
		}
		

		AddUnion(&q, 1);
		US.push(q);
		while(!US.empty()){
			q = US.front();
			US.pop();
			int t;
			for(t=1;t<=N;t++){
				if(!q.State[t])break;
			
			}
			if(t>N){
				Max = max(Max, q.B);
				continue;
			}
			for(i=0;i<U[t].C;i++){
				p = q;
				if(p.State[U[t].D[i]]) continue;
				AddUnion(&p, U[t].D[i]);
				US.push(p);
			}
			AddUnion(&q, t);
			US.push(q);
		}
		cout << Max << endl;
	}
}

Measured memory_bytes: 19000