akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const signed INF_=1001001001; const int INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":"\n");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n=IN;
    vector<int> a(n);
    cin>>a;
    map<int,int> cnt;
    REP(i,n) cnt[a[i]]++;
    int X=-1,Y=-1;
    ITR(i,rbegin(cnt),rend(cnt)) {
        if(X==-1 && i->second>=2) X=i->first,i->second-=2;;
        if(X!=-1 && Y==-1 && i->second>=2) Y=i->first,i->second-=2;
        if(X!=-1 && Y!=-1) break;
    }
    if(X==-1 || Y==-1) cout<<0<<endl;
    else cout<<X*Y<<endl;
    return 0;
}


Measured memory_bytes: 7296
#include <stdio.h>
int main(){
    int n1,n2,n3,sum=0;
    scanf("%d%d",&n1,&n2);

    if(0<n1&&n1<=100&&0<=n2&&n2>=n1){

        printf("Yes");
        }
        else {
            printf("No");
        }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,t,f=0;
    cin>>n;
    std::vector<ll> h(n);
    std::vector<ll> v(n,0);
    for (int i = 0; i < n; ++i)
    {
    	/* code */cin>>h[i];
    }
    for (int i = 0; i < n-1; ++i)
    {
    	if(h[i]-h[i+1]>1)
    		f=1;
    	else if(h[i]-h[i+1]==1 && v[i]!=0)
    		f=1;
    	else if(h[i]-h[i+1]==1){
    		v[i]=1;
    		v[i+1]=1;
    	}
    	else if(v[i]==1 && h[i]==h[i+1])
    		v[i+1]=1;
    }
    if(f==1)
    	cout<<"No";
    else cout<<"Yes\n";
}

Measured memory_bytes: 1792
// solv_B.cpp : 
//

#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>

using namespace std;

#define PRICE_MAX 100000

int main()
{
    int i, j, k;
    int x, y, c;

    int A, B, M;
    scanf("%d %d %d", &A, &B, &M);

    int* prices_A = new int[A];
    int* prices_B = new int[B];

    int price_A_min, price_B_min;

    price_A_min = PRICE_MAX;
    price_B_min = PRICE_MAX;
    

    for (i = 0; i < A; i++) {
        scanf("%d", &prices_A[i]);
        if (price_A_min > prices_A[i]) price_A_min = prices_A[i];
    }
    for (i = 0; i < B; i++) {
        scanf("%d", &prices_B[i]);
        if (price_B_min > prices_B[i]) price_B_min = prices_B[i];
    }

    int min_p = price_A_min + price_B_min;
    int p;

    for (k = 0; k < M; k++) {
        scanf("%d %d %d", &x, &y, &c);

        p = prices_A[x - 1] + prices_B[y - 1] - c;
        if (min_p > p) min_p = p;
    }

    printf("%d\n",min_p); 
    fflush(stdout);
    

    delete[] prices_A, prices_B;
    return 0;
}


Measured memory_bytes: 1024
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<double>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void input(BigNum* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atof(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atof(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::Num s;
	AtCoder::input(&s);

	const int a = s[0], b = s[1];

	if (a < b) {
		for (int i = 0; i < b; i++) {
			printf("%d", a);
		}
	} else {
		for (int i = 0; i < a; i++) {
			printf("%d", b);
		}
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

const ll MOD = 1e9+7;

ll my_pow(ll n, ll k)
{
    ll ret = 1;
    ll x = n;
    while(k > 0){
        if(k&1){
            ret *= x;
            ret %= MOD;
        }
        x = x * x;
        x %= MOD;
        k /= 2;
    }

    return ret;
}

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

    vector<ll> m(K+1);
    for(ll i=1; i<=K; i++) m[i] = i;

    ll ans = 0;
    for(ll i=1; i<=K; i++){
        ans += my_pow(K/i, N) * m[i];
        ans = (ans >= 0) ? ans % MOD : (MOD - (-ans)%MOD) % MOD;
        for(ll j=2; i*j<=K; j++) m[i*j] -= m[i];
    }

    cout << ans << endl;
    // debug(m);
}

Measured memory_bytes: 3556
s = input()
a = [int(x) for x in s]
for bit in range(1 << 3):
    tmp = a[0]
    tmps = str(a[0])

    for i in range(3):
        if bit >> i & 1:
            tmp += a[i + 1]
            tmps += '+' + str(a[i + 1])
        else:
            tmp -= a[i + 1]
            tmps += '-' + str(a[i + 1])
    if tmp == 7:
        print(tmps + '=7')
        exit()


Measured memory_bytes: 9116
#include <iostream>
#include <string>

using namespace std;

string translate (string s) {
  string ans = "";
  for (string::iterator itr = s.begin();
       itr != s.end(); itr++) {
    char c = *itr;
    if ('A' <= c && c <= 'Z') ans += c + ('a' - 'A');
    else ans += c;
  }
  return ans;
}

int main(int argc, char* argv[]) {
  string comp, tr_comp, str, tr_str;
  cin >> comp; tr_comp = translate(comp);

  int ans = 0;
  while (cin >> str) {
    if (str == "END_OF_TEXT") break;
    tr_str = translate(str);
    if (tr_str == tr_comp) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

typedef long long LL;

int main () {
        int k, s;
        LL ans = 0;
        cin >> k >> s;
        for (int i = 0; i <= k; i++) {
                for (int j = 0; j <= k; j++) {
                        if (s - i - j >= 0 && s - i - j <= k) {
                                ans++;
                        }
                }
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    int K;
    cin >> N >> K;
    string S;
    cin >> S;
    S[K - 1] = tolower(S[K - 1]);
    cout << S;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

typedef struct task
{
	int time;
	char name[10];
} task;

struct queue
{
	task container[1000005];
	int front, tail;
} queue;

int main()
{
	int n, runtime;
	queue.front = queue.tail = 0;

	scanf("%d %d", &n, &runtime);
	for (int i = 0; i < n; i++) {
		scanf("%s %d", queue.container[i].name, &queue.container[i].time);
		queue.tail++;
	}

	int timer = 0;
	while (queue.tail - queue.front > 0) { // Not empty
		if (queue.container[queue.front].time > runtime) {
			timer += runtime; // queue.container[queue.front % 100005].time;
			strcpy(queue.container[queue.tail % 1000005].name, queue.container[queue.front % 1000005].name);
			queue.container[queue.tail++ % 1000005].time = queue.container[queue.front++ % 1000005].time -= runtime;
		}
		else {
			timer += queue.container[queue.front % 1000005].time;
			printf("%s %d\n", queue.container[queue.front % 1000005].name, timer);
			queue.front++;
		}
	}

	return 0;
}

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

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

Measured memory_bytes: 3612
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
cnt=0
for i in range(n):
    if a[i]>=b[i]:
        a[i]-=b[i]
        cnt+=b[i]
    else:
        b[i]-=a[i]
        cnt+=a[i]
        if a[i+1]>=b[i]:
            a[i+1]-=b[i]
            cnt+=b[i]
        else:
            cnt+=a[i+1]
            a[i+1]=0
print(cnt)

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

char u[] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};
int v[] =  {1, 5, 10, 50, 100, 500, 1000};

int value_of (char c) {
  rep (i, 7) {
    if (c == u[i]) return v[i];
  }
}

int div(int a, int b, int n) {
  a %= b;
  a = a * 10;
  if (n == 1) return (a/b);
  return div(a, b, n - 1);
}

int main() {

  loop {
    int a, b, n;
    cin >> a >> b >> n;
    if (!cin) break;
    int sum = 0;
    range (i, 1, n + 1)
      sum += div(a,b,i);
    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
int gcd(int,int);

int main(){
  int x,y,n;

  scanf("%d%d",&x,&y);
  n=gcd(x,y);
  printf("%d\n",n);

  return 0;
}

int gcd(int x,int y){
  int r,n;
  
  if(x<y){
    r=y;
    y=x;
    x=r;
  }

  while(y>0){
    n=x%y;
    x=y;
    y=n;
  }

  return x;
}

Measured memory_bytes: 592
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine().toInt
  val s = StdIn.readLine()

  val all = s.distinct.sorted
  val r = (1 until n).foldLeft(0) { (ac, index) =>
    val r = s.splitAt(index)
    //println(r)
    scala.math.max(ac, all.foldLeft(0){ (acc, c) =>
      acc + (if(r._1.contains(c) && r._2.contains(c)) 1 else 0)
    })
  }
  
  println(r)
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int n;
vector<LL> a;

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    cin >> n;
    a.resize(n);
    LL ans = 0;
    inc(i, 0, n){
        cin >> a[i];
        ans += a[i]-1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N,M,C=map (int,input().split())
B=[]
b=list(input().split())
for _ in b:
    B.append(int(_))

Anser=0

for i in range(N):
    A=[]
    a=list(input().split())
    for _a in a:
        A.append(int(_a))
    temparr=[]
    for i in range(M):
        temparr.append(A[i]*B[i])
    if sum(temparr)+C>0:
        Anser+=1
print(Anser)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template <typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}
template<class 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;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    auto dp = make_v<int>(M,2,1<<N);
    fill_v(dp,INF);
    vi V(M);
    vi A(M);
    REP(i,M){
        int b;
        cin >> A[i] >> b;
        REP(j,b){
            int C;
            cin >> C;
            V[i]+= 1 << (C-1);
        }
    }
    
    dp[0][0][0] = 0;
    REP(i,M){
        if(i != 0){
            REP(j,SZ(dp[i][0]))dp[i][0][j] = min(dp[i-1][0][j],dp[i-1][1][j]);
        }
        REP(j,(1<<N)){
            REP(k,N){
                if((V[i] & (1 << k)) != 0){
                    if((j & (1 << k)) == 0){
                        chmin(dp[i][1][j + (1 << k)],min(dp[i][1][j],dp[i][0][j] + A[i]));
                    }
                }
            }
        }
    }
    int ans = min(dp[M-1][0][(1 << N)-1],dp[M-1][1][(1<<N)-1]);
    if(ans == INF)cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 32384
#include<iostream>
#include<cstring>
#define ll long long
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 2e5+5;
ll dp[405][405], a[405], pre[405];
int n;

ll dfs(int l, int r){
	if(l >= r) return a[l];
	if(dp[l][r]) return dp[l][r];
	ll res = 1e17;
	for(int i = l; i < r; i++){
		res = min(res, dfs(l, i) + dfs(i+1, r));
	}
	return dp[l][r] = res + pre[r] - pre[l-1];
}

int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		pre[i] = pre[i-1] + a[i];
	}
	for(int len = 1; len < n; len++){
		for(int i = 1; i <= n; i++){
			int j = len + i;
			if(j > n) break;
			ll res = 1e17;
			for(int k = i; k < j; k++){
				res = min(res, dp[i][k] + dp[k+1][j]);
			}
			dp[i][j] = res + pre[j] - pre[i-1];
		}
	}
	cout << dp[1][n] << endl;
	return 0;
}

Measured memory_bytes: 4876
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;
}
template <class T>
void printv(vector<T> v)
{
    for (T t : v)
    {
        cout << t << " ";
    }
    cout << '\n';
}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N, K;
    cin >> N >> K;

    cout << N%K << endl;

    return 0;
}


Measured memory_bytes: 256
while True:
    (n,total)=map(int,input().split())
    
    if (n,total) == (0,0):
        break
    
    # copmb: number of combinations
    comb = 0

    if total<=(n+(n-1)+(n-2)):
        for biggest in range(n,2,-1):
            for smallest in range(1,n-1,1):
                if (total-biggest-smallest)>smallest and (total-biggest-smallest)<biggest:
                    comb = comb+1
    print(comb)



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

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

    string s1, s2;
    cin >> s1 >> s2;
    if (s1 == s2.substr(0, s1.size()) && s1.size() + 1 == s2.size())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a); (i)<=(b); (i)++)
#define REP(i,N) FOR((i), 0, (N)-1)

bool isATCG(char a){
    if(a == 'A')return true;
    if(a == 'T')return true;
    if(a == 'C')return true;
    if(a == 'G')return true;
    return false;
}

int main(){
    string S;
    int a[11];
    cin >> S;
    REP(i,S.size()){
        if(i == 0)a[i] = isATCG(S[i]) ? 1 : 0;
        else a[i] = isATCG(S[i]) ? a[i-1]+1 : 0;
    }
    int ans = 0;
    REP(i, S.size()){
        ans = max(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
k, x = map(int, input().split())
l = max((k - 1) * -1 + x, -1000000)
r = min((k - 1) + x, 1000000)
res = ""
for i in range(l, r + 1):
  res += str(i)
  if i != r:
    res += " "
print(res)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,m,fa[100005],a[100005],b[100005],x,y;
long long s;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*f;
}
int find(int r){return fa[r]?fa[r]=find(fa[r]):r;}
int main(){
	n=read(),m=read();
	if(m==n-1) return 0*puts("0");
	if(m<n-m-2) return 0*puts("Impossible");
	for(int i=1;i<=n;++i) a[i]=read(),s+=a[i];
	for(int i=1;i<=m;++i){
		x=read(),y=read();
		x=find(x+1),y=find(y+1);
		s-=max(a[x],a[y]);
		b[i]=max(a[x],a[y]);
		if(a[x]>a[y]) fa[x]=y;else fa[y]=x;
	}
	sort(b+1,b+m+1);
	for(int i=1;i<=n-m-2;++i) s+=b[i];
	printf("%lld",s);
}
//既然输入的都是树，并且要求加的边的点权最小，不妨将每一棵树考虑成一棵根节点值最小的树
//显然最优的情况就是把每一棵树的顶点和剩下最小的n-m-2个点连接（根->根->子节点->根->子节点->根...用n-m-2个点串n-m棵树） 
//用并查集维护根最小，先把所有点加入sum，每次加入边的时候找它们所在树的根，把大的点从sum里删除并并入小的点所在的树 
//这样就可以保证每次处理时sum只剩下当前所有树的根节点之和 
//最后剩下的sum一定是所有树的根的和
//排序一下剩下的点，取最小的n-m-2个点计入sum即为答案 

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i=0; i<N; i++) cin>>A[i];
    vector<long long> CS(N+1), CX(N+1);
    for(int i=0; i<N; i++){
        CS[i+1] = CS[i] + A[i];
        CX[i+1] = CX[i] ^ A[i];
    }
    long long l=1, r=1;
    long long res = 0;
    for(l=1; l<=N; l++){
        while(r<=N && (CS[r]-CS[l-1])==(CX[r]^CX[l-1])){
            r++;
        }
        res += r-l;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4992
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    S = list(input().rstrip())

    c = lambda x: ord(x) - ord('a')
    tree = [SegmentTree(N, lambda x,y:x|y) for _ in range(26)]
    for i, l in enumerate(S):
        tree[c(l)].update(i, 1)

    Q = int(input())
    for _ in range(Q):
        t, a, b = input().rstrip().split()
        if t == '1':
            a = int(a) - 1
            tree[c(S[a])].update(a, 0)
            tree[c(b)].update(a, 1)
            S[a] = b
        else:
            a, b = int(a)-1, int(b)-1
            ans = 0
            for i in range(26):
                t = tree[i].query(a, b+1)
                ans += 1 if t else 0
            print(ans)

class SegmentTree:
    def __init__(self, n=None, f=max, zero_factory=int, converter=lambda x:x, initial_values=None):
        assert(n, initial_values)
        size = n if n else len(initial_values)
        self.__f, self.__z, self.__c = f, zero_factory, converter
        self.__n = 1 << ((size - 1).bit_length())
        self.__dat = [zero_factory() for _ in range(2 * self.__n)]
        if initial_values:
            zi = self.__get_leaf(0)
            for i, v in enumerate(initial_values): self.__dat[zi + i] = converter(v)
            for i in range(zi-1, -1, -1): self.__dat[i] = f(*self.__get_children(i))

    def update(self, index, value):
        i, v = self.__get_leaf(index), self.__c(value)
        if self.__dat[i] == v: return
        self.__dat[i] = v
        while i:
            i = self.__get_parent(i)
            self.__dat[i] = self.__f(*self.__get_children(i))

    def query(self, from_inclusive, to_exclusive):
        ans = self.__z()
        if to_exclusive <= from_inclusive: return ans
        l, r = self.__get_leaf(from_inclusive), self.__get_leaf(to_exclusive) - 1
        while r - l > 1:
            if self.__is_right(l): ans = self.__f(ans, self.__dat[l])
            if self.__is_left(r): ans, r = self.__f(ans, self.__dat[r]), r-1
            l, r = l//2, self.__get_parent(r)
        ans = self.__f(ans, self.__dat[l])
        if l != r: ans = self.__f(ans, self.__dat[r])
        return ans

    def __get_leaf(self, i): return self.__n + i - 1
    def __get_parent(self, i): return (i-1)//2
    def __get_children(self, i): return (self.__dat[2*i+1], self.__dat[2*i+2])
    def __is_left(self, i): return i&1 == 1
    def __is_right(self, i): return i&1 == 0

if __name__ == '__main__':
    main()


Measured memory_bytes: 435904
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep (i ,n) for(int i=0;i<(n);i++) 
ll gcd (ll a,ll b) {return b?gcd(b,a%b):a;}   
ll lcm (ll a,ll b) {return a/gcd(a,b)*b;} 
const int mod=1e9+7;
int main(){
		int l[100005],r[100005],a[100005];
		int n;
		cin>>n;
		for(int i=1;i<=n;i++)cin>>a[i];
		for(int i=1;i<=n;i++)l[i]=__gcd(a[i],l[i-1]);
		for(int i=n;i>=1;i--)r[i]=__gcd(a[i],r[i+1]);
		
		int res=0;
		
		for(int i=1;i<=n;i++){
			int gcd=__gcd(l[i-1],r[i+1]);
			res=max(res,gcd);
		}
		cout<<res<<endl;
		return 0;
}

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


ll lcm(ll a, ll b){
  if(a < b) return lcm(b, a);
  ll r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

ll gcd(ll a, ll b){
  ll ret = (a * b)/lcm(a,b);
  return ret;
}


int main(){
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll e = gcd(c, d);
  
  ll c_min, c_max, c_num;
  if(a%c == 0){
  	c_min = (ll)(a/c) * c;
  }else{
    c_min = (ll)(a/c) * c + c;
  }
  c_max = (ll)(b/c) * c;
  if(c_max == 0 && c_min == 0){
    c_num = 0;
  }else{
  	c_num = c_max/c - c_min/c + 1;
  }
  ll d_min, d_max, d_num;
  if(a%d == 0){
  	d_min = (ll)(a/d) * d;
  }else{
    d_min = (ll)(a/d) * d + d;
  }
  d_max = (ll)(b/d) * d;
  if(d_max == 0 && d_min == 0){
    d_num = 0;
  }else{
    d_num = d_max/d - d_min/d + 1;
  }
  ll e_min, e_max, e_num;
  if(a%e == 0){
  	e_min = (ll)(a/e) * e;
  }else{
    e_min = (ll)(a/e) * e + e;
  }
  e_max = (ll)(b/e) * e;
  if(e_max == 0 && e_min == 0){
    e_num = 0;
  }else{
    e_num = e_max/e - e_min/e + 1;
  }
  
  ll ans = (b - a + 1) - (c_num + d_num - e_num);

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

#define int long long

signed main() {
	int H, W;
	char tmp[101][101] = {};
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> tmp[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout <<tmp[i][j];
		}
		cout << endl;
		for (int j = 0; j < W; j++) {
			cout << tmp[i][j];
		}
		cout << endl;
	}

	return 0;
}



Measured memory_bytes: 256
/*
problem's name: atcoder arc 94-b
statue:Accepted
writer:Patrick_y
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const ll INF=20050208;
/*------------main part------------*/




int main()
{
	ll n;
	cin>>n;
	ll a,b,p;
	ll ans=0;
	while(n--)
	{
		cin>>a>>b;
		p=a*b;
		ll t=sqrt(p);
		if(t*(t+1)<p)
		{
			ans=t*2-1;
		}
		else if(t*t==p)
		{
			if(a==b)
			{
				ans=(t-1)*2;
			}
			else
			{
				ans=(t-1)*2-1;
			}
		}
		else
		{
			ans=(t-1)*2;
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
const int inf = 100100100;


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

  rep(i,k) cout << "ACL";
  cout << endl;
  
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	string S;
	cin >> S;

	ll ans = 0;
	for (int i = 0; i < S.length(); i++) {

		ans++;

		if (i+1 < S.length() && S[i] == S[i + 1]) {
			if (i + 1 != S.length() - 1) {
				ans++;
			}
			i+=2;
		}


	}

	cout << ans;



}


Measured memory_bytes: 720
n, m = map(int, input().split())

transit = []
transit_ = []

for a,b in (map(int, input().split()) for _ in range(m)):
    if a == 1:
        transit.append(b)
    if b == n:
        transit_.append(a)

if set(transit)&set(transit_):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

int main()
{
    int n, k;
    string s;
    scanf("%d %d",&n, &k);
    cin>>s;
    int len = s.size();

    s[k - 1] = s[k - 1] + 32;


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

int main()
{
    int n, k;
    string s;
    scanf("%d %d", &n, &k);
    cin>>s;
    s[k - 1] = tolower(s[k - 1]);
    cout<<s;
    return 0;
}
*/



Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int dp[100010];

    int main(){
      int n;
      cin >> n;
      int h[n];
      rep(i,n)cin >> h[i];
      int ans=0;
      dp[1]=abs(h[1]-h[0]);
      for(int i=0;i<=n-3;i++){
       dp[i+2]=min(dp[i]+abs(h[i]-h[i+2]),dp[i+1]+abs(h[i+1]-h[i+2])); 
      }
      cout << dp[n-1] << endl;
      return 0;}


Measured memory_bytes: 1024
pat :: Int -> Int -> [[Int]]
pat n y = [[a,b,c]| a <- [0..n], b <- [0..n-a], let c = n - a - b, 10000*a+5000*b+1000*c == y]

main :: IO ()
main = do
  [n,y] <- map read . words <$> getLine
  let ps = pat n y
  let xs = if null ps then [-1,-1,-1] else head ps
  putStrLn $ unwords $ map show xs


Measured memory_bytes: 636
A = int(input())
B = int(input())
C = int(input())
X = int(input())

rst = 0
for i in range(A+1):
    if i*500 > X:
        break
    for j in range(B+1):
        if i*500 + j*100 > X:
            break
        for k in range(C+1):
            if i*500 + j*100 + k*50 > X:
                break
            if i*500 + j*100 + k*50 == X:
                rst += 1
print(rst)

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

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


Measured memory_bytes: 256
#include<stdio.h>

int main()
{

	int n,a[10000],i,max,min;
	long sum;
	max=0;
	sum=0;
	min=1000000;
		
	scanf("%d\n%d",&n,&a[0]);

	sum=min=max=a[0];

	for(i=1;i<n;i++){
		scanf("%d",&a[i]);
		if(max<a[i])
			max=a[i];
		if(min>a[i])
			min=a[i];	
	
		sum+=a[i];
	}

	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a, b, c;
int main(){
	while(~scanf("%d %d %d",&a, &b, &c)){
		if(c >= a && c <= b) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long LL;

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

int main(void) {
	int n, a[100] = {0};
	LL dp[100][21] = {0};
	cin >> n;
	REP(i, n) scanf("%d", &a[i]);
	
	dp[n-1][a[n-1]] = 1;
	for (int i = n - 2; i >= 1; --i) {
		for (int j = 0; j <= 20; ++j) {
			if (j + a[i] <= 20) dp[i][j] += dp[i + 1][j + a[i]];
			if (j - a[i] >= 0) dp[i][j] += dp[i + 1][j - a[i]];
		}
	}
	cout << dp[1][a[0]] << endl;
	return 0;
}

Measured memory_bytes: 1264
n=int(input())
a=list(map(int,input().split()))
m=10**9+7
b=[0]*3
ans=1
for i in a:
  ans*=b.count(i)
  ans%=m
  for j in range(3):
    if b[j]==i:
      b[j]+=1
      break
print(ans%m)

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

using namespace std;
int main()
{
    int n,k;
    cin>>n;
    cin>>k;
    vector<int>v(n);
    for(auto &x:v)
    {
        cin>>x;
    }
    vector<vector<int> >dp(k+1,vector<int>(2,0));
    dp[0][0]=1;
    dp[0][1]=0;
   for(int i=1;i<=k;i++)
   {
       for(int j=0;j<2;j++)
       {
           bool isp=0;
           for(int m=0;m<n;m++)
           {
               if(v[m]<=i)
               {
                   if(dp[i-v[m]][j]==not j)
                   {
                       isp=1;
                   }
               }
           }
           if(isp)
           {
               dp[i][j]=j;
           }
           else 
           {
               dp[i][j]=not j;
           }
       }
   }
   if(dp[k][0])
   cout<<"Second";
   else
   cout<<"First";
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

lli d[510][510];

lli length=100;

void func(long long A, long long B){

    REP(i,length/2,length){
        REP(j,0,length){
            d[i][j]=1;
        }
    }

    A--;
    B--;

    for(lli i=length/2+1;i<length;i+=2){
        if(A==0)break;
        for(lli j=0;j<length;j+=2){
            if(A==0)break;
            d[i][j]=0;
            A--;
        }
    }

    for(lli i=0;i<length/2;i+=2){
        if(B==0)break;
        for(lli j=0;j<length;j+=2){
            if(B==0)break;
            d[i][j]=1;
            B--;
        }
    }

    cout<<length<<" "<<length<<endl;
    REP(i,0,length){
        REP(j,0,length){
            cout<<(d[i][j]?'#':'.');
        }
        cout<<endl;
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    func(A, B);
    return 0;
}


Measured memory_bytes: 3944
import copy
import random
import time


def down(d, last, c):
    result = 0
    for i in range(26):
        result += c[i] * (d - last[i])
    return result


def calc_score_of_the_day(S, d, t, last, C):
    return S[d][t] - down(d+1, last, C) + C[t] * (d+1 - last[t])


def main():
    start = time.time()
    D = int(input())
    C = [int(c) for c in input().split()]

    S = [0] * D

    for d in range(D):
        S[d] = [int(s) for s in input().split()]

    last = [0] * 26
    scores = [float('-inf')] * D

    result = 0
    T = [0] * D
    for d in range(D):
        next_t = 0
        score = float('-inf')
        for t in range(26):
            s = calc_score_of_the_day(S, d, t, last, C)
            if s > score:
                score = s
                next_t = t
        last[next_t] = d + 1
        result += score
        scores[d] = result
        T[d] = next_t + 1


    while time.time() - start < 1.9:
        result = scores[-1]
        change_date = 4 #random.randint(0, D-1)
        change_from = T[change_date]
        change_to = 13 # random.randint(1, 26)

        if change_from == change_to:
            continue
        copied_T = copy.copy(T)
        copied_T[change_date] = change_to

        last_of_the_day = [t if t < change_date else 0 for t in last]
        copied_scores = copy.copy(scores)
        for d in range(change_date, D):
            t = copied_T[d] - 1
            score = calc_score_of_the_day(S, d, t, last_of_the_day, C)
            last_of_the_day[t] = d + 1
            before = copied_scores[d-1] if d > 0 else 0
            copied_scores[d] = before + score
            copied_T[d] = t + 1
        if copied_scores[-1] > result:
            scores = copied_scores
            T = copied_T



    for t in T:
        print(t)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9980
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := readInt()
	l := make([]int, n)
	for i := range l {
		l[i] = readInt()
	}

	sort.Ints(l)
	ans := 0
	for i := range l {
		for j := i + 1; j < len(l); j++ {
			if idx := sort.SearchInts(l, l[i]+l[j]) - 1; idx > j {
				ans += idx - j
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
from heapq import heappop, heappush
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
jobs = [[] for i in range(M)]
for i in range(N):
    A, B = map(int, input().split())
    if A - 1 < M:
        jobs[A - 1].append(-B)

ans = 0
hq = []

for i in range(M):
    for j in jobs[i]:
        heappush(hq, j)
    if hq:
        ans += -heappop(hq)

print(ans)

Measured memory_bytes: 17732
#include <stdio.h>
#include <math.h>

int main (){

	int count=0;
	int point[10000]={};
	int input = 0;
	int max=0;

	int result = 0;
	int prime[1000000]= {};
	int sq_num=0;
	int deli=0;
	int i=0;
	while(1){
	  scanf("%d",&input);
	  if(input == 0 ){
		break;
	  }
	  count = 0;
	  prime[2]=1;
	  i=3;
	  while(1){
		prime[i]=1;
		i++;
		prime[i]=0;
		i++;
		if( i > 1000000){
		  break;
		}
	  }
	  i=input;
	  sq_num = (int)sqrt(2*i);
	  i=2;	
	  while(1){
		if(prime[i]==1){
		  deli=i;
		  while( input*2 > deli ){
			deli += i;
			prime[deli] = 0;
		  }
		}
		i++;
		if(sq_num < i){
		  break;
		}
	  }
	  i=input;
	  i++;
	  while(1){
		if(prime[i] == 1){
		  result++;
		}
		i++;
		if (2*input < i){
		  break;
		}
	  }
	  if(input == 0 ){
		break;
	  }
	  printf("%d\n",result);
	  result = 0;
	}
	
	return 0;
}

Measured memory_bytes: 4516
/*                          The four Truths of Life

                                    CKMKB
                                    PKMKB

                                    CKMKC
                                    PKMKC
*/


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <climits>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define ye cout<<"YES";
#define no cout<<"NO";
#define ln cout<<"\n";
// cout<<"Case #"<<ts<<": “;
//priority_queue < pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;


using namespace std;

ll mod(ll x, ll m) {
	return (x % m + m) % m;
}

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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll t = 1, r, n, a, d, c, b, x, y, sum, cnt, i, j, k, m, l, q, maxx, minn, temp, ans, flag, g, ts;
	ll mod = 1000000007;
	char ch, chh;
	double dans;
	string str, ttr;

	//cin >> t;


	for (ts = 1; ts <= t; ts++)
	{
		flag = 0; sum = 0; cnt = 0; ans = 0; k = 0; maxx = 0; minn = 0; a = 0; b = 0; temp = 0;

		cin >> n;
		ll arr[n]; for (i = 0; i < n; i++) {cin >> arr[i];}

		sort(arr, arr + n);

		sum = arr[n - 1]; cnt = 1;

		for (i = n - 2; i >= 0; i--)
		{
			if (cnt == n - 1)
				break;
			sum += arr[i];
			cnt++;
			if (cnt == n - 1)
				break;
			sum += arr[i];
			cnt++;
			if (cnt == n - 1)
				break;

		}

		cout << sum;




		ln
	}
	return 0;
}


Measured memory_bytes: 5180
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sn = new Scanner(System.in);
        
        String s = sn.nextLine();
        
        if((s.substring(0,1)).equals(s.substring(1,2))
            && (s.substring(1,2)).equals(s.substring(2,3))) {
              System.out.print("No");  
              return;
        }
        
        System.out.print("Yes");
    }
}


Measured memory_bytes: 21716
#include <assert.h>
#include <climits>
#include <iostream>
#include <string>

struct TNode
{
	int Value;
	TNode* Parent;
	TNode* Left;
	TNode* Right;
	
	TNode();
	TNode(int AValue, TNode* AParent);
};

TNode::TNode()
{
	Value  = INT_MAX;
	Parent = NULL;
	Left   = NULL;
	Right  = NULL;
}

TNode::TNode(int AValue, TNode* AParent)
{
	Value = AValue;
	Parent = AParent;
	Left   = NULL;
	Right  = NULL;
}
void Insert(int Key, TNode* Root);
void Delete(TNode* Root)
{
	if(Root == NULL) return;
	Delete(Root->Left);
	Delete(Root->Right);
	delete Root;
}

void AddLeft(int Key, TNode* Root)
{
	assert(Root != NULL);
	if(Root->Left == NULL){
		TNode* Left = new TNode(Key, Root);
		Root->Left = Left;
	}else{
		Insert(Key, Root->Left);
	}
}

void AddRight(int Key, TNode* Root)
{
	assert(Root != NULL);
	if(Root->Right == NULL){
		TNode* Right = new TNode(Key, Root);
		Root->Right = Right;
	}else{
		Insert(Key, Root->Right);
	}
}

void Insert(int Key, TNode* Root)
{
	assert(Root != NULL);
	if(Root->Value == Key) return;
	if(Root->Value == INT_MAX){
		Root->Value = Key;
		return;
	}
	if(Root->Value > Key){
		AddLeft(Key, Root);
	}else{
		AddRight(Key, Root);
	}
}

bool Find(int Key, TNode* Node)
{
	if(Node == NULL) return false;
	if(Node->Value == Key) return true;
	if(Node->Value > Key) return Find(Key, Node->Left);
	return Find(Key, Node->Right);
}

void OutputPreOrder(const TNode* Root)
{
	if(Root == NULL) return;
	std::cout << " " << Root->Value;
	OutputPreOrder(Root->Left);
	OutputPreOrder(Root->Right);
}

void OutputInorder(const TNode* Root)
{
	if(Root == NULL) return;
	OutputInorder(Root->Left);
	std::cout << " " << Root->Value;
	OutputInorder(Root->Right);
}

void Print(const TNode* Node)
{
	OutputInorder(Node);
	std::cout << std::endl;
	OutputPreOrder(Node);
	std::cout << std::endl;
}

void Execute(const std::string& Command, TNode* Root)
{
	if(Command == "insert"){
		int Key = 0;
		std::cin >> Key;
		Insert(Key, Root);
		return;
	}
	if(Command == "find"){
		int Key = 0;
		std::cin >> Key;
		if(Find(Key, Root)){
			std::cout << "yes" << std::endl;
			return;
		}
		std::cout << "no" << std::endl;
	}
	if(Command == "print"){
		Print(Root);
	}
}

int main()
{
	int Count = 0;
	std::cin >> Count;
	TNode* Root = new TNode();
	for(int i = 0; i < Count; ++i){
		std::string Command;
		std::cin >> Command;
		Execute(Command, Root);
	}
	Delete(Root);
	return 0;
}

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

int main(){
  float x1,y1,x2,y2,x3,y3,xp,yp;
  float a1,b1,a2,b2,A,B;
  while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>xp>>yp){
    a1=x2-x1;
    a2=y2-y1;
    b1=x3-x1;
    b2=y3-y1;
    xp=xp-x1;
    yp=yp-y1;
    A=(b1*yp-b2*xp)/(a2*b1-a1*b2);
    B=(a2*xp-a1*yp)/(a2*b1-a1*b2);
    if(A+B<1&&A>0&&B>0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define ji -
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define fe(x) for(int i=be[x];i;i=e[i].ne)
using namespace std;
int n,p,a[60];
long long f[60][2];
int main(){
	scanf("%d%d",&n,&p);
	fo(i,1,n){
		scanf("%d",&a[i]);
		a[i]=a[i]&1;
	}
	f[0][0]=1;
	fo(i,0,n-1){
		fo(j,0,1){
			f[i+1][j]+=f[i][j];
			f[i+1][j^a[i]]+=f[i][j];
		}
	}
	printf("%lld\n",f[n][p]);
	return 0;
}

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

const int MAX_N = 5005, MAX_V = 5005;
int N, K, dp[MAX_N][MAX_V], a[MAX_N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> N >> K;
    for(int i=0;i<N;i++) cin >> a[i];

    sort(a, a+N);

    int left = -1, right = N;
    while(1<right-left){
        int mid = (left+right) / 2;
        if(K<=a[mid]) {right = mid; continue;}
        
        for(int i=0;i<=N;i++) for(int j=0;j<=K;j++) dp[i][j] = 0;
        dp[0][0] = 1;
        swap(a[mid], a[N-1]);
        for(int i=0;i<N-1;i++){
            for(int j=0;j<=K;j++){
                dp[i+1][j] |= dp[i][j];
                if(a[i]<=j) dp[i+1][j] |= dp[i][j-a[i]];
            }
        }
        swap(a[mid], a[N-1]);
        bool ok = false;
        for(int i=max(0, K-a[mid]);i<K;i++) if(dp[N-1][i]) ok = true;
        if(ok) right = mid;
        else left = mid;
    }

    cout << left + 1 << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
    string S; cin >> S;
    vector<int> alpha(26,0);
    rep(i, S.size()) alpha[S[i] - 'a']++;
    rep(i, 26) {
        if (alpha[i] == 0) {
            cout << char('a' + i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
a, b, k = map(int,input().split())
if a >= 1:
  if a >= k:
    print(a-k, b)
  else:
    if b >= 1:
      if b >= (k-a):
        print(0, b-(k-a))
      else:
        print(0, 0)
    else:
      print(0, 0)
else:
  if b >= k:
    print(0, b-k)
  else:
    print(0, 0)

Measured memory_bytes: 3060