akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
   int a,b;
   char op;
while(1){
    cin>>a>>op>>b;
   if(op=='?'){break;}
   if(op=='+'){
       cout<<a+b<<endl;
   }
   if(op=='-'){
       cout<<a-b<<endl;
   }
   if(op=='*'){
       cout<<a*b<<endl;
   }
   if(op=='/'){
       cout<<a/b<<endl;
   }
}
}


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

using namespace std;

int main()
{
	int n; cin >> n;
	vector<int> arr(n);
	for (int i = 0; i < n; i++) cin >> arr[i];

	bool ok = true;
	for (int x : arr) {
		if (x % 2 == 0 && x % 3 != 0 && x % 5 != 0)
			ok = false;
	}
	cout << (ok ? "APPROVED" : "DENIED") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FORD(i,a,b) for(int i=(a);i>=b;i--)
#define FOR(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
using namespace std;
int main() {
	string s;
	cin>>s;
	FOR(i,0,s.size())cout<<"x"; 
	return 0;
}


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

	cin >>n>>k;
	vector<int>h(n);

	rep(i,n){
		cin >> h[i];
	}
	sort(h.begin(),h.end());
	reverse(h.begin(),h.end());
	if (k>n){
		cout << "0"<<endl;
		return 0;
	}
	rep(i,k){
		h[i]=0;
	}
	long long sum=0;
	rep(i,n){
		sum+=h[i];
	}
	cout <<sum<<endl;
	return 0;
}


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

int main() {
	ll a, b, c, x, y, ans = 0;
	cin >> a >> b >> c >> x >> y;
	if (a / 2 + b / 2 < c) ans = a * x + b * y;
	else {
		ans = c * min(x,y) * 2;
		if (x > y && a > c * 2) ans += (x - y) * c * 2;
		if (x > y && a <= c * 2) ans += (x - y) * a;
		if (x < y && b > c * 2) ans += (y - x) * c * 2;
		if (x < y && b <= c * 2) ans += (y - x) * b;
	}
	cout << ans;
	return 0;
}

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back()
#define B begin()
#define E end()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define nl "\n"
#define fat 1000000007

int main()
{
    boost
    int n;
    cin >> n;

    string s;
    cin >> s;

    if(n%2)
    {
        cout << "No\n";
        return 0;
    }
    else
    {
        for(int i = 0; i < n / 2; i++)
        {
            if(s[i] != s[i + n / 2])
            {
                cout << "No\n";
                return 0;
            }
        }
        cout << "Yes\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int ll;
ll big= 1000000007;
int main()
{
	int n,m;
	cin >> n >> m;

	if(abs(n-m)>1){
		cout << "0" << endl;
	}else if(abs(n-m)==1){
		ll ans=1;
		for(int i=1; i<=n; i++){
			ans*=i;
			if(ans>big){
				ans %= big;
			}
		}
		for(int i=1; i<=m; i++){
			ans*=i;
			if(ans>big){
				ans %= big;
			}
		}
		cout << ans << endl;
	}else{
		ll ans=1;
		for(int i=1; i<=n; i++){
			ans*=i;
			if(ans>big){
				ans %= big;
			}
		}
		for(int i=1; i<=m; i++){
			ans*=i;
			if(ans>big){
				ans %= big;
			}
		}	
		ans *= 2;
		if(ans>big){
			ans %= big;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
 string S;
  cin >> S;
  int count = 0;
  
  for(int i = 0; i < 3; i++) {
    if(S.at(i) =='1') {
      count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define int long long
#define INF 1145141919810364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int h, w, n, x, y;
string s, t;

signed main() {
	cin >> h >> w >> n >> y >> x >> s >> t;
	int xmi = x, xma = x , ymi = y, yma = y;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'L')xmi--;
		else if (s[i] == 'R')xma++;
		else if (s[i] == 'U')ymi--;
		else yma++;
		if (xmi <= 0 || w < xma || ymi <= 0 || h < yma) {
			cout << "NO" << endl;
			return 0;
		}
		if (t[i] == 'L')xma = max(xma - 1, (int)1);
		else if (t[i] == 'R')xmi = min(xmi + 1, w);
		else if (t[i] == 'U')yma = max(yma - 1, (int)1);
		else ymi = min(ymi + 1, h);
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 776
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<deque>
#include<queue>
#define ll long long int
#define ld long double
#define pi acos(-1)
#define pb push_back
using namespace std;

int main()
{
    ll i,j,a,k,b,c,n,t,m,p,q,d,e,f,y,g,z,h,r,l,x,o;
    ld aa,bb,cc,ee,dd,ff,kk,gg;
    vector< ll > v,s,vv;
    map<ll,vector<ll> > me;
    map<ll,ll > sa,ta,pa,ma;
    priority_queue<ll, vector<ll>, greater<ll> > aq,tq,pq;
    string st,et,ft,pt,ct;
    deque<ll> de,pe,ne;
    ios_base::sync_with_stdio(false);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a>>b;
        c = a+b;
        v.pb(c);
        d = a-b;
        s.pb(d);
    }
    sort(v.begin(),v.end());
    sort(s.begin(),s.end());
    e = max((v[n-1]-v[0]),(s[n-1]-s[0]));
    cout<<e<<endl;
}


Measured memory_bytes: 6648
#include<iostream>
using namespace std;
int main()
{
	int t,d[3];
	cin>>d[0]>>d[1]>>d[2];
	for(int i=1;i<3;i++)
	for(int j=0;j<3-i;j++)
	  if(d[j]<d[j+1])
	  {
	  	  t=d[j];
	  	  d[j]=d[j+1];
	  	  d[j+1]=t;
	  }
	cout<<d[0]*10+d[1]+d[2];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  double M=1.0/2;
  
  if(N%2 != 0)
    M = ((N+1.0)/2.0)/(double)N;
  
  cout << std::setprecision(10) << M <<endl;
  
}

Measured memory_bytes: 256
icase=0
if icase==0:
    s=input()
    yyyy=int(s[0:4])
    mm=int(s[5:7])
    dd=int(s[8:])
    if yyyy<2019:
        print("Heisei")
    elif yyyy==2019 and mm<4:
        print("Heisei")
    elif yyyy==2019 and mm==4 and dd<=30:
        print("Heisei")
    else:
        print("TBD")

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

typedef long long ll;
typedef pair<ll,int> P;

#define rep(i,x) for(int i = 0 ; i < x ; i ++)
#define rep1(i,x) for(int i = 1 ; i <= x ; i ++)
#define pb push_back
#define sor(vec) sort(vec.begin(),vec.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define fr first
#define sc second

const ll INF = 1000000000000000000;

struct bit{
	int siz;
	P s[8200];
	void init(){
		siz = 1<<13;
		rep1(i,siz){
			s[i] = P(-INF,0);
		}
	}
	void updata(int a,P x){
		while(a <= siz){
			if(s[a].fr < x.fr)s[a] = x;
			a += a&-a;
		}
	}
	P query(int a){
		P ret = P(-INF,0);
		if(a == 0)return ret;
		while(a > 0){
			if(ret.fr < s[a].fr)ret = s[a];
			a -= a&-a;
		}
		return ret;
	}
}bit;

int main(){
	int n;
	ll a[4002];
	scanf("%d",&n);
	rep1(i,n)scanf("%lld",&a[i]);
	
	ll sum[4002];
	static P dp[4002][4002];
	sum[0] = 0;
	rep1(i,n)sum[i] = sum[i-1] + a[i];
	rep1(i,n)dp[i][1] = P(sum[i],0);
	for(int j = 1 ; j <= n ; j ++){
		vector<ll> Z;
		for(int i = 1 ; i <= n ; i ++){
			Z.pb(sum[i]+dp[i][j].fr);
		}
		sor(Z);
		bit.init();
		for(int i = j ; i <= n ; i ++){
			dp[i][j+1] = bit.query(lb(Z,sum[i])-Z.begin());
			if(dp[i][j+1].fr == -INF)dp[i][j+1].fr = INF;
			else dp[i][j+1].fr = sum[i]-dp[i][j+1].fr;
			bit.updata((lb(Z,sum[i]+dp[i][j].fr)-Z.begin())+1,P(sum[i],i));
		}
	}
	for(int j = n ; j >= 1 ; j --){
		if(dp[n][j].fr != INF){
			vector<int> ans;
			int loc = n;
			while(1){
				loc = dp[loc][j].sc;
				j --;
				if(loc == 0)break;
				ans.pb(loc);
			}
			printf("%d\n",(int)ans.size()+1);
			reverse(ans.begin(),ans.end());
			rep(i,ans.size()){
				printf("%d%c",ans[i],(i==(int)ans.size()-1)?'\n':' ');
			}
			if(ans.size() == 0)puts("");
			return 0;
		}
	}
}

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

vector<ll>divisor(ll n) {
  vector< ll > res;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      res.emplace_back(i);
      if(i != n / i) res.emplace_back(n / i);
    }
  }
  return res;
}

int main() {
  int n,ans = 0;
  cin >> n;
  vector<int>a(n);
  rep(i,0,n) cin >> a[i];
  vector<int>cnt(n,0);
  vector<bool>in(n,false);
  for(int i = n-1;i >= 0;i--){
    if(cnt[i] != a[i]){
      ans++;
      in[i] = true;
      vector<ll>div = divisor(i+1);
      for(int j = 0;j < div.size();j++) cnt[div[j]-1] = (cnt[div[j]-1]+1)%2;
    }
  }
  cout << ans << endl;
  rep(i,0,n){
    if(in[i]) cout << i+1;
    if(i != n-1) cout << " ";
    else cout << "" << endl;
  }
}

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

H, W = [int(x) for x in input().split()]
ans = 0

if H == 1 and W == 1:
    print(1)
    sys.exit()

if H == 1 or W == 1:
    print(1)
    sys.exit()

# type2
b = H // 2

# type1
a = H - b

ans += b * (W // 2)
ans += a * (W - (W // 2))

print(ans)





Measured memory_bytes: 38384
from sys import stdin, setrecursionlimit


def main():
    h, n = map(int, stdin.readline().split())
    ab = []
    max_a = 0
    for _ in range(n):
        a, b = map(int, stdin.readline().split())
        if a > max_a:
            max_a = a
        ab.append([a / b, a, b])

    ab.sort(reverse=True)

    dp = [0] * (h + max_a)

    for i in range(h + max_a):
        dp[i] = (i // ab[0][1] + 1) * ab[0][2]

    for i in range(h):
        for j in range(n):
            dp[i + ab[j][1]] = min(dp[i + ab[j][1]], dp[i] + ab[j][2])

    print(min(dp[h - 1:]))


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


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

int main(){
 string S;
   cin>>S;
  char preop;
  for(int i=0;i<S.size();i++){
   char op;
    op = S.at(i);
    if(op == preop){
         cout<<"Bad"<<endl;
      break;
    }else if (i == S.size()-1){
      cout<<"Good"<<endl;
    }
    preop=op;
  }
      
  }
   

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

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

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int M;cin >> M;
  cout << 48-M << endl;
  return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    int W[n+1],E[n+1];
    fill(W,W+n+1,0);
    fill(E,E+n+1,0);
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            char c;
            cin>>c;
            W[j+1]+=(c=='W');
            E[j+1]+=(c=='E');
        }
    }
    for(int i=1;i<=n;i++){
        W[i]+=W[i-1];
        E[i]+=E[i-1];
    }
    int ans=-1,cost=100000000;
    for(int i=0;i<=n;i++){
        //i,i+1????¢????
        int err = E[i]+W[n]-W[i];
        if(err<cost){
            ans=i; cost=err;
        }
    }
    cout<<ans<<' '<<ans+1<<endl;

    return 0;
}

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

int main () {
  ios_base :: sync_with_stdio (0);
  cin.tie (nullptr);
  cout.tie (nullptr);
  int a, b, c;
  cin >> a >> b >> c;
  if (b + c > a) {
    cout << c - a + b;
  }
  else {
    cout << 0;
  }
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] X = new int[N];
		int[] XS = new int[N];
		for(int i=0; i<N; i++) {
			X[i] = sc.nextInt();
			XS[i] = X[i];
		}Arrays.sort(XS);

		for(int j=0; j<N; j++) {
			if(X[j] * 2 > XS[N/2-1] + XS[N/2]) {
				System.out.println(XS[N/2-1]);
			}else {
				System.out.println(XS[N/2]);
			}
		}

	}

}


Measured memory_bytes: 90060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#undef int
#define mk make_pair
#define pb push_back
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;

string s, t;

signed main()
{
    cin >> s >> t;
    int N = s.size();
    const int M = t.size();
    s += s;
    for(int i = 0; i < N; i++){
        //cout << s.substr(i, M) << endl;
        if(t == s.substr(i, M)){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");

    return 0;
}

/*



*/



Measured memory_bytes: 3224
#include<iostream>
#include<map>
#include<unordered_map>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long double ld;
#define mp make_pair
#define pb push_back

#define rep(i, N) for(ll i = 0; i < N; i++)
#define repa(i, a, N) for(ll i = a; i < N; i++)
#define repr(i, N) for(ll i = N-1; i >= 0; i--)

#define drep(i, N, j, M) rep(i, N) rep(j, M)
#define trep(i, N, j, M, k, L) rep(i, N) rep(j, M) rep(k, L)

#define all(A) A.begin(), A.end()

// const ll mod = 1e9 + 7;
const ll mod = 998244353;

const ll LLMAX = numeric_limits<long long>::max();

void No() {
	cout << "No" << endl;
}

void Yes() {
	cout << "Yes" << endl;
}

ll id(char c) {
	return c - 'a';
}

template<class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
	return os << "{" << p.first << "," << p.second << "}";
}

template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
	os << "{";
	for (auto e : v)os << e << ",";
	return os << "}";
}

int main() {
	ll N;

	cin >> N;
	ll ans = 0;

	vi L(N);

	rep(i, N) {
		cin >> L[i];
	}
	sort(all(L));

	rep(i, N-2) {
		ll a = L[i];
		repa(k, i+1, N - 1) {
			ll b = L[k];

			auto itr = lower_bound(all(L), a+b);
			ans += max(0LL, itr - L.begin() - k - 1);
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int A,B,T;
  cin >> A>> B>>T;
  cout << (T/A) *B << endl;

}


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

#define ll long long
#define ld long double
#define ull unsigned long long
#define pw(x) (1LL << (x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"

using namespace std;

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

    string s;
    cin >> s;

    s[5] = s[13] = ' ';

    cout << s;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
 
int main()
{
	int t;
	cin>>t;
	map<string,int> mp;
	for (int i = 0; i < t; ++i)
	{
		string s;
		cin>>s;

		mp[s] = i;
	}
	cout<<mp.size()<<endl;
	return 0;
}

Measured memory_bytes: 19256
#include<bits/stdc++.h>
using namespace std;
const int maxx=1e5+2;
typedef long long ll;
char str[20];
int num[30];
unordered_map<string,ll> mp;
int main(){
    int n; cin>>n;
    ll ans=0;
    for(int i=1;i<=n;i++){
        scanf("%s",str+1);
        for(int j=1;j<=26;j++) num[j]=0;
        for(int j=1;j<=10;j++){
            num[str[j]-'a'+1]++;
        }
        string x="";
        for(int j=1;j<=26;j++){
            if(num[j]==10){
                x+='A';
            }else{
                x+=(char)('0'+num[j]);
            }
        }
        ans+=mp[x];
        mp[x]++;
        //cout<<x<<endl;
    }
    cout<<ans<<endl;
}


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

int main(){

    int a;
    cin >> a;

    int ans = 0;
    ans += a*(a*(a+1)+1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int INF=(int)1e9;
const int MOD=(int)1e9+7;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

int main(){
 int H,W;
 cin>>H>>W;
 char c[105][105];
 set<int>seth;
 set<int>setw;
 for(int h=1;h<=H;h++){
   int cont=0;
   for(int w=1;w<=W;w++){
     cin>>c[h][w];
     if(c[h][w]=='#')cont++;
   }
   if(cont==0)seth.insert(h);
 }

 for(int w=1;w<=W;w++){
   int cont=0;
   for(int h=1;h<=H;h++){
     if(c[h][w]=='#')cont++;
   }
   if(cont==0)setw.insert(w);
 }

 for(int h=1;h<=H;h++){
   if(seth.find(h)!=seth.end())continue;
   for(int w=1;w<=W;w++){
     if(setw.find(w)!=setw.end())continue;
     cout<<c[h][w];
   }
   cout<<endl;
 }
 return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		int[]A = new int[N];
		string[] str = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str[i]);
		}
		int[]B = new int[N];
		int[]C = new int[N];
		var list = new List<int>();
		for(var i=N-1;i>=0;i--){
			int ct = 0;
			for(var j=i;j<N;j=j+(i+1)){
				ct += B[j];
			}
			if((A[i]+ct)%2==1){
				B[i] = 1;
				list.Add(i+1);
			}
		}
      	list.Sort();
		Console.WriteLine(list.Count);
		if(list.Count>0){
			Console.Write(list[0]);
			for(var i=1;i<list.Count;i++){
				Console.Write(" "+list[i]);
			}
		}
	}
}

Measured memory_bytes: 29780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////



int main(){fastio
    ll a,b,c;cin>>a>>b>>c;
    ll sum=a+b+c;
    if(sum>=22){
        cout<<"bust";
    }else{
        cout<<"win";
    }
    
    
    return 0;
}


Measured memory_bytes: 256
// C++ program to find if a number is divisible by
// 9 or not
#include<bits/stdc++.h>
using namespace std;

// Function to find that number divisible by 9 or not
int check(string str)
{
	// Compute sum of digits
	int n = str.length();
	int digitSum = 0;
	for (int i=0; i<n; i++)
		digitSum += (str[i]-'0');

	// Check if sum of digits is divisible by 9.
	return (digitSum % 9 == 0);
}

// Driver code
int main()
{
	string str ;
	cin>>str;
	check(str)? cout << "Yes" : cout << "No ";
	return 0;
}


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

int cnt = 0;
int memo[30][10];

int main(void) {
	memset(memo, 0, sizeof(memo));
	for(int j = 0; j < 10; j++) memo[0][j] = 1;

	for(int i = 1; i < 30; i++) {
		for(int j = 0; j < 10; j++) {

			memo[i][j] += memo[i-1][j];
			if(j != 0) memo[i][j] += memo[i-1][j-1];
			if(j != 9) memo[i][j] += memo[i-1][j+1];

			if(j == 0) {
				cnt += memo[i][j];
			}
		}
	}

	int K;
	cin >> K;

	int cnt = 0;
	int digit = -1;
	int ans = -1;

	for(int i = 0; i < 30; i++) {
		bool flag = false;
		for(int j = 0; j < 10; j++) {
			if(j == 0) continue;
			if(cnt < K and K <= cnt + memo[i][j]) {
				digit = i;
				ans = j;
				K -= cnt;
				flag = true;
				break;
			}
			cnt += memo[i][j];
		}

		if(flag) break;
	}

	string ret = to_string(ans);

	for(int i = digit-1; i >= 0; i--) {
		int sum = 0;
		if(ans != 0) {
			if(K <= memo[i][ans-1]) {
				ret += to_string(ans-1);
				ans--;
				K -= sum;
				continue;
			}
			sum += memo[i][ans-1];
		}

		if(sum < K and K <= sum + memo[i][ans]) {
			ret += to_string(ans);
			K -= sum;
			continue;
		}
		sum += memo[i][ans];

		if(ans != 9) {
			if(sum < K and K <= sum + memo[i][ans+1]) {
				ret += to_string(ans+1);
				ans++;
				K -= sum;
				continue;
			}
		}
	}

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll A, B, K, i;

    cin >> A >> B >> K;

    for(i=1; i<=K; i++){
        if(i%2==1){
            if(A%2==1) A--;

            A -= A/2; B += A;      
        }

        else{
            if(B%2==1) B--;

            B -= B/2; A += B;
        }
    }

    cout << A << " " << B << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
  
  list($n) = explode(" ", trim(fgets(STDIN)));
  $h = explode(" ", trim(fgets(STDIN)));

  $c_max = 0;
  $c = 0;
  for($i=0; $i<$n-1; $i++){
    if($h[$i] >= $h[$i+1]){
      $c++;
    }else{
      $c_max = max($c_max, $c);
      $c=0;
    }
  }
  $c_max = max($c_max, $c);

  echo $c_max;

Measured memory_bytes: 14840
#include <stdio.h>

main() {
  int n, m, i, j;
  char a, t[100];

  while(1) {
    scanf("%d", &n);
    if(n==0) break;
    
    for(i=0 ; i<n*2 ; i++) {
      scanf(" %c", &t[i]);
    }
    
    scanf("%d", &m);
    for(i=0 ; i<m ; i++) {
      scanf(" %c", &a);
      for(j=0 ; j<n*2 ; j+=2) {
	if(a == t[j]) {
	  a = t[j+1];
	  break;
	}
      }
      printf("%c", a);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
def solve(s):

    dic = {}
    ll = 'qwertasdfgzxcvb'
    rr = 'yuiophjklnm'

    for l_i in list(ll):
        dic[l_i] = -1

    for r_i in list(rr):
        dic[r_i] = 1

    ans = 0
    prev = 0

    for s_i in s:
        current = dic[s_i]
        if current != prev:
            if abs(current - prev) == 2:
                ans += 1

        prev = current

    return ans


while 1:
    s = raw_input()
    if s == '#':
        break

    print(solve(s))

Measured memory_bytes: 6420
/*
  AtCoder Grand Contest 027
  A - Candy Distribution Again

  方針
    基本的には必要なお菓子が少ない子供から配るのが良いです。
    
    今回気をつけなければいけないのが、子供iは"ちょうどa_i個"のお菓子を
    もらうと喜ぶ点です。
    したがって、もしまだお菓子をあげていない子供がいれば、残りのお菓子を
    その子供にあげればよいですが、全員にお菓子をあげてしまっていた場合は
    、その中の一人に余分にお菓子をあげることになるので、喜ぶ子供の人数は
    １人減ります。

  実装
    上記の方針通りに実装すればよい。
*/

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int N, x;
vector<int> a;

int main() {
  scanf("%d%d", &N, &x);
  a = vector<int>(N);
  for (int i = 0; i < N; ++i) scanf("%d", &a[i]);

  sort(a.begin(), a.end());

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (x < a[i]) break;
    x -= a[i];
    cnt += 1;
  }

  if (x > 0 && cnt == N) cnt -= 1;

  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <tuple>
#include <string>
#include <set>
#include <map>
using namespace std;
using ll = long long;



int main() {
	int k;
	string s;
	cin >> k >> s;
	if (s.length() <= k) cout << s << endl;
	else cout << s.substr(0, k)+"..." << endl;

	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int limit = scanner.nextInt();
        int lower = scanner.nextInt();
        int upper = scanner.nextInt();
        String num = new String();
        int tmp = 0;
        int sum = 0;

        for(int i=0; i<=limit; i++) {
            num = Integer.toString(i);
            for(int j=0; j<num.length(); j++) {
                tmp += Character.getNumericValue(num.charAt(j));
            }
            if(tmp >= lower && tmp <= upper) {
                sum += i;
            }
            tmp = 0;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 22356
#include<bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int n, m, a[N];
struct info {
	int l, r, index;
} q[N];
inline bool cmp(info x, info y) { return x.r < y.r; }
int ans[N], pre[N];
namespace BIT
{
	int tree[N];
	inline int lowbit(int x) { return x & -x; }
	inline void modify(int x, int val) {
		for (; x <= N; x += lowbit(x)) tree[x] += val;
	} 
	inline int query(int x) {
		int ans = 0;
		for (; x; x -= lowbit(x)) ans += tree[x];
		return ans;
	}
	inline int query(int l, int r) {
		return query(r) - query(l - 1);
	}
}
using namespace BIT;
int main(){
	scanf ("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) scanf ("%d", &a[i]);
	
	for (int i = 1; i <= m; i++) {
		scanf ("%d%d", &q[i].l, &q[i].r);
		q[i].index = i;
	}
	sort(q + 1, q + m + 1, cmp);
	
	int j = 1;
	for (int i = 1; i <= m; i++)
	{
		while (j <= q[i].r) {
			if (pre[a[j]]) modify(pre[a[j]], -1);
			modify(j, 1);
			pre[a[j]] = j;
			j++;
		}
		ans[q[i].index] = query(q[i].l, q[i].r);
	}
	
	for (int i = 1; i <= m; i++) printf ("%d\n", ans[i]);
  return 0;
}

Measured memory_bytes: 17400
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll a, b, c, d; cin >> a  >> b  >> c >> d;
    ll ans = a*c;
    ans = max(ans,a*d);
    ans = max(ans,b*d);
    ans = max(ans,b*c);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <queue>


//使用队列实现广度优先搜索

using namespace std;

static const int N=100;
static const int INFTY=(1<<21);

/**
 * M 邻接矩阵
 * queue 记录下一个待访问顶点的队列
 * 将七点s到各顶点的最短距离记录在d[i]中
 */

int n,M[N][N];
int d[N];

void bfs(int s){
    queue<int> q;
    q.push(s);
    for(int i=0;i<n;i++){
        d[i]=INFTY;
    }
    d[s]=0;
    int u;
    while(!q.empty()){
        u=q.front(),q.pop();

        for(int v=0;v<n;v++){
            if(M[u][v]==0)
                continue;
            if(d[v]!=INFTY)
                continue;
            d[v]=d[u]+1;
            q.push(v);
        }
    }
    for(int i=0;i<n;i++){
        cout<<i+1<<" "<<(d[i]!=INFTY?d[i]:(-1))<<endl;
    }
}


int main(){
    int u,k,v;

    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            M[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            v--;
            M[u][v]=1;
        }
    }

    bfs(0);
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b;cin>>a>>b;
    rep(i,0,10000001){
        double u=0.08*i,uu=0.1*i;
        int aa=u,bb=uu;
        if(aa==a&&bb==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}








Measured memory_bytes: 256
O = input()
E = input()
al = ""
for o,e in zip(O,E):
  al += o
  al += e
if len(O) > len(E):
  #print(len(O) - len(E))
  for i in range(abs(len(O) - len(E)),0,-1):
    al += O[-i]
elif len(E) > len(O):
  for i in range(abs(len(O) - len(E)),0,-1):
    al += E[-i]
# for i in range(1,len(O) + len(E) + 1):
#   if i % 2 == 1:
#     al += O[i]
#   else:
#     al += E[i]
print(al)

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

#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<

int main(){
  ll n, x;
  cin >> n >> x;
  ll i;
  vector<ll> child(n);
  for(i = 0; i < n ; i++){
    cin >> child[i];
  }
  sort(ALL(child));
  
  ll result = 0;
  for(i = 0; i < n && x > 0; i++){
    x -= child[i];
    if(x >= 0 && i != n - 1)
      result++;
    else if(x == 0 && i == n - 1)
      result++;
  }
      
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
x,n=map(int,input().split())
p=list(map(int,input().split()))
ans=[10**9]*102
for i in range(102):
    if not i in p:
        ans[i]=abs(i-x)
m=0
ms=10**9
for i in range(102):
    if ans[i]<ms:
        ms=ans[i]
        m=i
print(m)



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

long long n, ans = 1, now = 1;

int main() {
  cin >> n;
  while(1) {
    ++now;
    if(now * now > n) break;
    ans = now * now;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
    int x, y, buf;
    while(true) {
        cin >> x >> y;
        if (x == 0 && y == 0) {
            break;
        }
        
        if (x > y) {
            buf = x;
            x = y;
            y = buf;
        }
        cout << x << " " << y << endl;
    }
}


Measured memory_bytes: 3016
from functools import lru_cache
N, X = map(int, input().split())
S = sorted([int(a) for a in input().split()])[::-1]
P = 10**9+7
fact = [1]
for i in range(N+10):
    fact.append(fact[-1]*(i+1)%P)

@lru_cache(None)
def calc(k, x):
    if k >= N:
        return x
    if x < S[-1]:
        return (x*fact[N-k]) % P
    return (calc(k+1, x%S[k]) + calc(k+1, x) * (N-k-1)) % P

print(calc(0, X))


Measured memory_bytes: 160336
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    if (s == "SUN"){
        cout << 7;
    }else if (s == "MON"){
        cout << 6;
    }else if (s == "TUE"){
        cout << 5;
    }else if (s == "WED"){
        cout << 4;
    }else if (s == "THU"){
        cout << 3;
    }else if (s == "FRI"){
        cout << 2;
    }else if (s == "SAT"){
        cout << 1;
    }else
    return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T1, typename T2> 
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  int aa, bb;
  cin >> aa >> bb;
  string c;
  cin >> c;
  if (c == a) aa--;
  if (b == c) bb--;
  cout << aa << " " << bb << "\n";
  return 0;
}


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

using namespace std;

int main()
{
    char c;

    cin >> c;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// aising2020_e
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int T;
    cin >> T;
    while (T--){
        int N;
        cin >> N;

        vector<vector<int>> left(N+1);
        vector<vector<int>> right(N+1);
        ll ans = 0;
        REP(i, N){
            int k, l, r;
            cin >> k >> l >> r;
            if (l > r){
                left[k].emplace_back(l-r);
                ans += r;
            } else {
                right[N-k].emplace_back(r-l);
                ans += l;
            }
        }

        priority_queue<int, vector<int>, greater<int>> pq_l, pq_r;

        REP(k, N+1){
            for (auto x: left[k]){
                pq_l.emplace(x);
                ans += x;
            }

            while (pq_l.size() > k){
                ll x = pq_l.top(); pq_l.pop();
                ans -= x;
            }
        }

        REP(k, N+1){
            for (auto x: right[k]){
                pq_r.emplace(x);
                ans += x;
            }

            while (pq_r.size() > k){
                ll x = pq_r.top(); pq_r.pop();
                ans -= x;
            }
        }

        print(ans);
    }


    return 0;
}


Measured memory_bytes: 18112
#include<bits/stdc++.h>
#define ll  long long int
#define db long double 
#define ull unsigned long long int
// #define mp make_pair
#define F first
#define S second
#define pb push_back
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
#define Nmax 1000005
// #define INF 10000000000000
#define MOD 1000000007
#define MAXN 200005
 
using namespace std;

ll mod=998244353;
 
ll expo(ll base,ll exponent,ll mod){
    ll ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

const ll M=3000006;
ll f[M],inv[M];

void compute(){
    f[0]=1;
    rep(i,1,M-1){
        f[i]=(1LL*i*f[i-1])%mod;
    }
    inv[M-1]=expo(f[M-1],mod-2,mod);
    for(ll i=M-2;i>=0;i--){
        inv[i]=(1LL*(i+1)*inv[i+1])%mod;
    }
}
ll C(ll n,ll r){
    return (1LL*((1LL*f[n]*inv[r])%mod)*inv[n-r])%mod;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // compute();
    int tests=1;
    // cin>>tests;    
    while(tests--)
    {
    	ll i,j,k,n;
    	cin>>n;
    	bool flag=false;
    	ll cnt=0;
    	rep(i,1,n)
    	{
    		cin>>j>>k;
    		if(j==k) cnt++;
    		else cnt=0;
    		if(cnt>=3) flag=true;
    	}
    	if(flag) cout<<"Yes";
    	else cout<<"No";

    }

    return 0;
}
    

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  vector<int> max(n, 0);
  max[0] = a[0];

  for (int i = 1; i < n; i++) {
    if (max[i - 1] <= a[i])
      max[i] = a[i];
    else
      max[i] = max[i - 1];
    // cout << max[i];
  }

  ll ans = 0;

  for (int i = 0; i < n; i++) {
    ans += max[i] - a[i] >= 0 ? max[i] - a[i] : 0;
  }
  cout << ans << endl;
}

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

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

    rep(i, MAX_N){
        rep(j, MAX_N){
            if(i == j){
                G[i][j] = 0;
                G2[i][j] = 0;
            }else{
                G[i][j] = INF;
                G2[i][j] = INF;
            }
        }
    }

    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        ll c; cin >> c;
        G[a][b] = c;
        G[b][a] = c;
    }

    rep(k,n){
        rep(i,n){
            rep(j,n){
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }

    rep(i,n){
        rep(j,n){
            if(i != j && G[i][j] <= l){
                G2[i][j] = 1;
            }
        }
    }

    rep(k,n){
        rep(i,n){
            rep(j,n){
                G2[i][j] = min(G2[i][j], G2[i][k] + G2[k][j]);
            }
        }
    }

    rep(i,n){
        rep(j,n){
            if(G2[i][j] > 0)G2[i][j]--;
            if(G2[i][j] > 9999)G2[i][j] = -1;
        }
    }

    int q; cin >> q;
    rep(i,q){
        int s, t; cin >> s >> t;
        s--; t--;
        cout << G2[s][t] << endl;
    }
    
    return 0;
}
 
 


Measured memory_bytes: 2048
#include<stdio.h>
int main(void){
    int W,H,x,y,r;
    scanf("%d%d%d%d%d%d",&W,&H,&x,&y,&r);
    if((x-r<0||x+r>W)||(y-r<0||y+r>H)){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#define int long long
const int inf=1145141919;
const int mod=1000000007;
using namespace std;
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
int H,W;
int p[50][50],q[50][50];
signed main(){
	int i,j;
	cin>>H>>W;
	for(i=0;i<H;i++){
		string s;
		cin>>s;
		for(j=0;j<W;j++)
			p[i][j]=(s[j]=='.')?0:1;
	}
	for(i=0;i<H;i++)
		for(j=0;j<W;j++){
			if(p[i][j]==1)
				q[i][j]=-1;
			else{
				if(i>0)
					q[i][j]+=p[i-1][j];
				if(j>0)
					q[i][j]+=p[i][j-1];
				if(i<H-1)
					q[i][j]+=p[i+1][j];
				if(j<W-1)
					q[i][j]+=p[i][j+1];
				if(i>0&&j>0)
					q[i][j]+=p[i-1][j-1];
				if(i>0&&j<W-1)
					q[i][j]+=p[i-1][j+1];
				if(i<H-1&&j>0)
					q[i][j]+=p[i+1][j-1];
				if(i<H-1&&j<W-1)
					q[i][j]+=p[i+1][j+1];
			}
		}
	for(i=0;i<H;i++){
		for(j=0;j<W;j++)
			if(q[i][j]==-1)
				cout<<"#";
			else
				cout<<q[i][j];
		cout<<endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long n;
cin>>n;
long long a[n],s=0;
for(int i=0;i<n;i++)
{
if((i+1)%3==0||(i+1)%5==0)
a[i]=0;
else
a[i]=i+1;
s=s+a[i];
}
cout<<s;
}


Measured memory_bytes: 11356
#include<stdio.h>

int main(){
 int l1,l2,dia,rc,lc;
 rc=lc=0;
 while(scanf("%d,%d,%d",&l1,&l2,&dia)!=EOF){
  if(l1*l1+l2*l2==dia*dia){
   rc++;
  }
  if(l1==l2){
   lc++;
  }
 }
 printf("%d\n%d\n",rc,lc);
 return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    int n, m, l, r;
    cin >> n >> m;
    cin >> l >> r;
    for (int i = 1; i < m; i++) {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        l = max(l, tmp1);
        r = min(r, tmp2);
    }
    if (r - l + 1 > 0) cout << r - l + 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a, b, k, f;
int main(){
	scanf("%d%d%d", &k, &a, &b);
	for(int i=a; i<=b; i++){
		if(i%k==0){
			printf("%s", "OK");
			f=1;
			break;
		}
	}
	if(f==0) printf("%s", "NG");
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int h[1000000];
int dp[1000000];
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>h[i];
    }
    dp[1]=0;
    dp[2]=abs(h[1]-h[2]);
    for(int i=3; i<=n; i++)
    {
        if(dp[i-2]+abs(h[i]-h[i-2])<dp[i-1]+abs(h[i]-h[i-1]))
        {
            dp[i]=dp[i-2]+abs(h[i]-h[i-2]);

        }
        else
        {
            dp[i]=dp[i-1]+abs(h[i]-h[i-1]);

        }
    }


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


Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

vector <vector <int> > mv;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	int n,m;
	cin>>n>>m;
	mv.resize(n);
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		mv[a].push_back(b);
		mv[b].push_back(a);
	}
	queue <int> mq;
	vector <int> vi(n,0);
	mq.push(0);
	vi[0]=1;
	while(!mq.empty()){
		int u = mq.front();
		mq.pop();
		for(int i=0;i<mv[u].size();i++)if(vi[mv[u][i]]==0){
			vi[mv[u][i]] = u+1;
			mq.push(mv[u][i]);
		}
	}
	cout<<"Yes\n";
	for(int i=1;i<n;i++)cout<<vi[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 9676
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
	string s;
	cin >> s;
	vector<int> a(26,0);

	for(int i=0;i<s.size();i++){
		a[s[i]-'a']++;
	}
	for(int i=0;i<26;i++){
		if(a[i]>1){
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

const int MAX_N = 1<<15;
//for sieve
//int z[MAX_N+1];
//int prime[MAX_N+1];
bool z[MAX_N+1];
vector<int> prime;

void erat();

int main()
{
        int count = 0;
        erat(); //cout << prime.size();
        int n;
        while(true){
                cin >> n;
                if(!n) break;
                for(int i=0;prime[i]<=(n/2);i++){
                        for(int j=0;j<prime.size();j++){
                                if(n == prime[i] + prime[j]){
                                        count++;
                                        //cout << prime[i] << ' ' << prime[j] << endl;
                                        break;
                                }
                        }
                }
                cout << count << endl;
                count = 0;
        }

        return 0;

}

void erat()
{
        for(int i=0;i<=MAX_N;i++) z[i] = true;
        z[0] = false; z[1] = false;
        for(int i=2;i<=MAX_N;i++){
                if(!z[i]) continue;
                prime.push_back(i);
                for(int j=i*i;j<=MAX_N;j+=i){
                        z[j] = false;
                }
        }
}

Measured memory_bytes: 1276