akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1'000'000'007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define reps(i, n)      for(int i = 1; (i) <= (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
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); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    vector<int> p(n), q(n);
    vector<int> sorted_p(n);
    rep(i, n){
        cin >> p[i];
        sorted_p[i] = p[i];
    }
    rep(i, n) cin >> q[i];

    sort(all(sorted_p));

    int cnt = 0, a = 0, b = 0;
    do{
        ++cnt;
        if(sorted_p == p) a = cnt;
        if(sorted_p == q) b = cnt;
    }while(next_permutation(all(sorted_p)));

    cout << abs(a - b) << endl;

return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Airplane | diff Airplane.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Airplane.cpp && ./a.out

/*
 
 6/9/2019
 
 5:00-
 
 */

int A[3];

void solve() {
  sort(A,A+3);
  cout<<(A[0]+A[1])<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A[0]>>A[1]>>A[2];
  solve();
  
  return 0;
}


Measured memory_bytes: 256
W, H, N = map(int,input().split())

min_x = 0
min_y = 0
max_x = W
max_y = H

width = max_x - min_x
height = max_y - min_y

for n in range(N):
    x, y, a = map(int,input().split())
    if a == 1:
        if min_x < x:
            min_x = x
    elif a == 2:
        if max_x > x:
            max_x = x
    elif a == 3 :
        if min_y < y:
            min_y = y
    else :
        if max_y > y:
            max_y = y
    
if min_x >= max_x or min_y >= max_y:
    output = 0
else:
    output = (max_x - min_x) * (max_y - min_y)

print(output)

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    string s; cin >> s;
    ll n = s.size();
    ll res = 0;
    
    for(int i=0;i<(1<<n-1);i++){
        ll ans = s[0] - '0';
        rep(j,n-1){
            if(i & (1<<j)){ //+が入るとき
                res +=ans;
                ans = s[j+1] - '0';
            }
            else{
                ans *= 10;
                ans += s[j+1] - '0';
            }
        }
        res += ans;
    }
    
    out(res);
}


Measured memory_bytes: 256
package main
import (
    "fmt"
    "sort"
)

func main(){
    var x, y, z, K int
    fmt.Scan(&x, &y, &z, &K)
    
    var one, two ,three []int
    for i, cake:=0, 0;i<x;i++{
        fmt.Scan(&cake)
        one = append(one, cake)
    }
    for i, cake:=0, 0;i<y;i++{
        fmt.Scan(&cake)
        for j:=0;j<x;j++{
            two = append(two, cake+one[j])
        }
    }
    sort.Sort(sort.Reverse(sort.IntSlice(two)))
    for i, cake:=0, 0;i<z;i++{
        fmt.Scan(&cake)
        for j:=0;j<K&&j<x*y;j++{
            three = append(three, cake+two[j])
        }
        
    }
    sort.Sort(sort.Reverse(sort.IntSlice(three)))
    for i:=0;i<K;i++{
        fmt.Println(three[i])
    }
    
}


Measured memory_bytes: 91136
a, b, c = map(int, input().strip().split())

count = 0

while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
    if a == b and b == c:
        count = -1
        break

    count += 1
    a1 = b // 2 + c // 2
    b1 = c // 2 + a // 2
    c1 = a // 2 + b // 2

    a, b, c = a1, b1, c1

print(count)


Measured memory_bytes: 3060
#include <stdio.h>
 
long long N, S;
long long ans;
 
long long f(long long b, long long n)
{
	return (b > n) ? n : f(b, n / b) + n % b;
}
 
long long func(void)
{
	long long i;
	long long k = 320000;
 
//	if (S > N / 2 + (N & 1LL)) return -1LL;
	if (N == S) return N + 1;
//	if (0 == N % S && N / S > 1) return N / S;
 
	if (k > N) k = N;

	for (i = 2LL; i <= k; ++i)
	{
		if (f(i, N) == S) return i;
	}

	for (i = N / k; i; --i)
	{
		if ((N - S) / i > 1 && f((N - S) / i + 1, N) == S) return (N - S) / i + 1;
	}
 
	return -1LL;
}
 
int main(void)
{
	scanf("%lld %lld", &N, &S); //printf("%lld\n", f(316227, N));
	printf("%lld\n", func());
 
	return 0;
}

Measured memory_bytes: 1708
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        char[] c = s.toCharArray();

        long k = sc.nextLong();

        long ans = 0;

        int cnt = 1;
        for (int i=0; i<s.length()-1; i++){
            if (c[i]==c[i+1]) {
                cnt++;
            }
        }
//        System.out.println(cnt);
        if (cnt==s.length()){
            System.out.println(((long)s.length()*k)/2);
        }else {
            if (c[0]==c[s.length()-1]){
                String t = s+s;
//                System.out.println(t);
                char[] cc = t.toCharArray();
                long tmp = 0;
                for (int j=0; j<t.length()-1; j++){
                    if (cc[j]==cc[j+1]){
                        tmp++;
                        j++;
                    }
                }
                for (int j=0; j<s.length()-1; j++){
                    if (c[j]==c[j+1]){
                        ans++;
                        j++;
                    }
                }
//                System.out.println(tmp);
//                System.out.println(ans);
                if (tmp == ans*2){
                    System.out.println(ans*k);
                }else {
                    System.out.println(ans+(ans+1)*(k-1));
                }

            }else {
                for (int i=0; i<s.length()-1; i++){
                    if (c[i]==c[i+1]){
                        ans++;
                        i++;
                    }
                }
                System.out.println(ans*k);
            }
        }
    }
}

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

void solve(int y, int m, int d) {
	if(y < 1868) {
		cout << "pre-meiji" << endl;
	} else if((y == 1868) && ((m < 9) || (m == 9 && d < 8))) {
		cout << "pre-meiji" << endl;
	} else if(y < 1912) {
		cout << "meiji" << ' ' << y - 1868 + 1 << ' ' << m << ' ' << d << endl;
	} else if((y == 1912) && ((m < 7) || (m == 7 && d < 30))) {
		cout << "meiji" << ' ' << y - 1868 + 1 << ' ' << m << ' ' << d << endl;
	} else if(y < 1926) {
		cout << "taisho" << ' ' << y - 1912 + 1 << ' ' << m <<  ' ' << d << endl;
	} else if((y == 1926) && ((m < 12) || (m == 12 && d < 25))){
		cout << "taisho" << ' ' << y - 1912 + 1 << ' ' << m <<  ' ' << d << endl;
	} else if(y < 1989) {
		cout << "showa" << ' ' << y - 1926 + 1 << ' ' << m <<  ' ' << d << endl;
	} else if((y == 1989) && (m == 1 && d < 8)) {
		cout << "showa" << ' ' << y - 1926 + 1 << ' ' << m <<  ' ' << d << endl;
	} else {
		cout << "heisei" << ' ' << y - 1989 + 1 << ' ' << m <<  ' ' << d << endl;
	}
}

int main(void) {
	int y, m, d;
	
	while(cin >> y >> m >> d) {
		solve(y, m ,d);
	}
	
	return 0;
}


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

const int mod = 1000*1000*1000 + 7;
int N, M;
struct Query {
    int l, x;
};
vector<vector<Query> > quer;

vector<vector<vector<int> > > cc;
int dp(int r, int g, int b) {
    int &ret = cc[r][g][b];
    if(ret != -1) return ret;

    int n = max(max(r, g), b);
    for(int i = 0; i < quer[n].size(); i++) {
        int l = quer[n][i].l, x = quer[n][i].x;
        if(r >= l) x--;
        if(g >= l) x--;
        if(b >= l) x--;
        if(x != 0) return ret = 0;
    }
    if(n == N) return 1;
    ret = dp(n + 1, g, b);
    ret += dp(r, n + 1, b); ret %= mod;
    ret += dp(r, g, n + 1); ret %= mod;
    return ret;
}

int main() {
    scanf("%d %d", &N, &M);
    quer.resize(N + 1);
    for(int i = 0; i < M; i++) {
        int l, r, x; scanf("%d %d %d", &l, &r, &x);
        quer[r].push_back({l, x});
    }
    cc = vector<vector<vector<int> > >(N + 1, vector<vector<int> >(N + 1, vector<int>(N + 1, -1)));
    int ans = dp(1, 0, 0);
    ans += dp(0, 1, 0); ans %= mod;
    ans += dp(0, 0, 1); ans %= mod;
    printf("%d", ans);
}


Measured memory_bytes: 110336
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs)        \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%ld", &xs[i]);
#define fillDouble(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%lf", &xs[i]);
#define fillString(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;
const int MAX_V = 100005;

struct mint {
    ll x;
    mint(ll x=0):x(x%mod){}

    mint& operator+=(const mint a) {
        if((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint& operator-=(const mint a) {
        if (x < a.x) {
          x += mod;
        }
        x -= a.x;
        return *this;
    }

    mint& operator*=(const mint a) {
        x = (x * a.x) % mod;
        return *this;
    }

    mint& operator/=(const mint a) {
        *this *= a.inv();
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }

    mint pow(ll n) const {
        mint a(*this);
        mint res = 1;
        while (n > 0) {
            if (n & 1) res *= a;
            a *= a;
            n >>= 1;
        }
        return res;
    }

    mint inv() const {
        return pow(mod - 2);
    }
};

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

  long n, m;
  cin >> n >> m;

  vector<long> x(n);
  vector<long> y(m);

  fillLong(x);
  fillLong(y);

  mint resX = 0;
  rep(i, n-1) {
    mint kake = (x[i+1] - x[i]);
    kake *= (i+1) * (n-i-1);
    resX += kake;
  }
  mint resY = 0;
  rep(i, m-1) {
    mint kake = (y[i+1] - y[i]);
    kake *= (i+1) * (m-i-1);
    resY += kake;
  }

  cout << (resX * resY).x << endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
 
#define wsp                cin >> ws;
#define sp                 setprecision            
#define sn(n)              scanf("%lld",&n)
#define cn(n)              cin>>n
#define pr(n)              printf("%lld\n",n)
#define ff                 first
#define ss                 second
#define prn                cout<<endl
#define str(n)             scanf("%s",n)
#define pb                 push_back
#define len(n)             n.length()
#define forp(i,a,b)        for(ll i=a;i<=b;i++)
#define rep(i,n)           for(ll i=0;i<n;i++)
#define forn(i,a,b)        for(ll i=a;i>=b;i--)
#define ren(i,n)           for(ll i=n-1;i>=0;i--)
#define LALIT              ios_base::sync_with_stdio(false);cin.tie(0)
#define tr(container, it)  for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define mem(n,m)           memset(n,m,sizeof(n))
#define mp                 make_pair
#define mod               1000000007                                                                             
 
using namespace std;
typedef unsigned long long int ull;
typedef   long long int          ll;
typedef pair<int, int>         pii;
typedef pair<ll, int>          pli;
typedef pair<double, int>      pdi;
typedef pair<ll, ll>           pll;
typedef pair<double, double>   pdd;
 
const int  N = int(100000)+5;

ll t , n , k  , cnt , sum , x , y , x2 , y2 , l , r , ans ;

ll a[N] , b[N]  ;

int main()
{
   LALIT ;
   cin >> n ;
   forp(i,1,2*n)cin >> a[i] ;
   sort(a+1,a+1+2*n) ;
   forp(i,1,2*n)
   {
   	  sum = sum + a[i] ;
   	  i++ ;
   }
   cout << sum ;
   return 0 ;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

int main(){
	fast;
	ll n;
	cin>>n;
	string s;
	cin>>s;
	vector<ll> color[3];
	for( ll i=0; i < n ;i++){
          if(s[i]=='R'){
               color[0].pb(i+1);
          }
          if(s[i]=='G'){
             color[1].pb(i+1);
          }
          if(s[i]=='B'){
            color[2].pb(i+1);
          }
	}
    ll ans = 0;
	for(ll center = 0;center < 3;center++){
	 	ll curr_size = size(color[center]);
	 	ll prev_size = size(color[(center-1+3)%3]);
	 	ll next_size = size(color[(1+center)%3]);
	 	ll prev = (center-1+3)%3;
	 	ll next = (center+1)%3;
		for(ll i = 0 ; i < curr_size ;i++){
			for( ll j = 0; j < prev_size; j++){
				if(color[prev][j] > color[center][i]){
					break;
				}
				auto it = lower_bound(all(color[next]),color[center][i]);
				ll index = it-color[next].begin();
				ll total = next_size-index;
				ll to_find = color[center][i]*2 - color[prev][j];
				if(binary_search(all(color[next]),to_find)){
                     total--;
				}
				ans = ans + max(0ll,total);
			}
			for( ll j = 0; j < next_size; j++){
				if(color[next][j] > color[center][i]){
					break;
				}
				auto it = lower_bound(all(color[prev]),color[center][i]);
				ll index = it-color[prev].begin();
				ll total = prev_size-index;
				ll to_find = color[center][i]*2 - color[next][j];
				if(binary_search(all(color[prev]),to_find)  ){
                     total--;
				}
				ans = ans + max(0ll,total);
			}
		}
	}

	cout<<ans<<endl;
}


// 1 2
// 3
// 4


Measured memory_bytes: 3744
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] balls = new int[n];
        Boolean[] bools = new Boolean[n];
        Arrays.fill(balls,1);
        Arrays.fill(bools,false);
        bools[0] = true;
        for(int i = 0; i < m; i++){
            int x = sc.nextInt()-1;
            int y = sc.nextInt()-1;
            balls[x]--;
            balls[y]++;
            if(bools[x]){
                bools[y] = true;
            }
            if(balls[x] == 0){
                bools[x] = false;
            }
        }
        int ans = 0;
        for(boolean b : bools){
            if(b) ans++;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 65112
<?php
  
 fscanf(STDIN,"%d%d",$n,$Y);
 for($x=0;$x<=$n;$x++){
   for($y=0;$y<=$n-$x;$y++){
     $z = $n-($y+$x);
     $z>=0 ? $z = $z : $z = 0;
     $sum_money = $x*10000+$y*5000+$z*1000;
     if($sum_money==$Y){
       echo $x." ".$y." ".$z;
       exit;
     }
   }
 }

echo "-1 -1 -1";

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define N 105
using namespace std;

int n,m;
string s[N];
string ss[N];
set<string> sss;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
        sss.insert(s[i]);
    }
    cin>>m;
    for(int i=0;i<m;i++)
        cin>>ss[i];
    set<string>::iterator it = sss.begin();
    int sum =  0;
    for(it;it!=sss.end();it++){
        int ans = 0;
        for(int i=0;i<n;i++)
            if(s[i]==*it)
                ans++;
        for(int i=0;i<m;i++)
            if(ss[i]==*it)
                ans--;
        if(ans)
            sum = max(sum,ans);
    }
    cout<<sum<<endl;
    return 0;
}

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

void find( int* a, int x, int y )
{
    int min = 2147483647;
    for( int i = x; i <= y; i++ )
        if( min > a[i] )
            min = a[i];
    cout << min << endl;
}

int main()
{
    int a[100000], n, q, x, y;
    bool com;

    for( int i = 0; i < 100000; i++ )
        a[i] = 2147483647;

    cin >> n >> q;
    for( int i = 0; i < q; i++ )
    {
        cin >> com >> x >> y;
        if( com == 1 )
            find( a, x, y );
        if( com == 0 )
            a[x] = y;
    }

    return 0;
}



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

int main()
{
    int n;
    while (cin >> n)
    {
        if (n == 0)
            break;
        vector<int> dp(n + 1);
        dp[0] = 1;
        for (int now = 0; now < n; now++)
        {
            for (int next = now + 1; next <= min(now + 3, n); next++)
            {
                dp[next] += dp[now];
            }
        }
        int ans = dp[n] / 3650 + 1;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3064
def func(cnt, cn):
    tmp = [0] * 13
    for i in range(13):
        nn = (cn + i) % 13
        tmp[nn] = cnt[i]
    return tmp


MOD = 10**9+7

s = list(input())
s.reverse()

cnt = [0]*13
cnt[0] = 1
t = 1
for ci in range(len(s)):
    t %= 13 
    if s[ci] != '?':
        cn = int(s[ci]) * t % 13
        cnt = func(cnt, cn)
    else:
        tmp = [0]*13
        add = [0]*13
        for cj in range(10):
            cn = cj * t % 13
            add = func(cnt, cn)
            for _ in range(13):
                tmp[_] += add[_]
                tmp[_] %= MOD
        cnt = tmp
    t *= 10
print(cnt[5])

Measured memory_bytes: 78176
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
#include <queue>
#include <set>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back

int main()
{
    string s;
    cin >> s;
    int A, Z;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'A')
        {
            A = i;
            break;
        }
    }
    for (int i = s.size() - 1; i < s.size(); i--)
    {
        if (s[i] == 'Z')
        {
            Z = i;
            break;
        }
    }
    cout << Z - A + 1 << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<pii, int> ppiii;
typedef pair<ll, ll> pll;
typedef pair<pii, pii> query;
typedef pair<ll, pii> key;

ll powTen[19];
// rev(n) - n == d
ll d;

map<key, ll> dp;

ll solve(ll diff, int lhs, int rhs) {
  {
    ll delta = 0;
    int a = lhs;
    int b = rhs;
    while(a <= b) {
      delta += powTen[b--] - powTen[a++];
    }
    delta *= 9;
    if(diff - delta > d || diff + delta < d) return 0;
  }
  key k = {diff, {lhs, rhs}};
  if(dp.count(k)) return dp[k];
  if(lhs > rhs) {
    return diff == d ? 1 : 0;
  }
  if(lhs == rhs) {
    return diff == d ? 10 : 0;
  }
  ll ret = 0;
  for(int x = 0; x <= 9; x++) {
    for(int y = (lhs == 0 ? 1 : 0); y <= 9; y++) {
      ret += solve(diff + (x-y) * (powTen[rhs] - powTen[lhs]), lhs+1, rhs-1);
    }
  }
  dp[k] = ret;
  return ret;
}

void solve() {
  powTen[0] = 1;
  for(int i = 1; i <= 18; i++) {
    powTen[i] = powTen[i-1] * 10;
  }
  cin >> d;
  ll ret = 0;
  for(int len = 1; len <= 18; len++) {
    ret += solve(0, 0, len-1);
  }
  cout << ret << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


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

int main(){
  long long n,k;
  cin >> n >> k;
  double p[200010];
  for(int i=0; i<n; i++) cin >> p[i];
  double s=0;
  for(int i=0; i<k; i++) s += p[i];
  double m=s;
  for(int i=k; i<n; i++){
    s += p[i]-p[i-k];
    m = max(m,s);
  }
  printf("%.1f", (m+k)/2.0);
  
}

Measured memory_bytes: 1792
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l(n);
  rep(i, n) cin >> l.at(i);
  int d = 0;
  int count = 1;
  int i = 0;
  //   while (d <= x && i < n) {
  //     d += l.at(i);
  //     count++;
  //     i++;
  //   }
  while (1) {
    if (i == n) break;
    if (d + l.at(i) > x) {
      break;
    } else {
      d += l.at(i);
      count++;
    }
    i++;
  }
  cout << count;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(e,s) (s.find(e)!=s.end())
using ll=long long int; using dd=double;
using pii=pair<int,int>; using pll=pair<ll,ll>;
typedef vector<int> vi;
ll INFLL=(ll)2e18, MOD=1e9+7;
const int INF=0x3f3fffff ;
///////////*//////// DEBUG /////////////////////////////////////////
#ifdef DEBUG
#define D(x) cerr<<#x<<" is: "<<x<<'\n';
#define DD(x,y) cerr<<"("<<#x<<","<<#y<<") are: "<<x<<" "<<y<<'\n';
auto tStart = chrono::system_clock::now(); //freopen("op.txt","w",stdout);
#else 
#define D(x) ;
#define DD(x,y) ;
#endif
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vi> adj; vi vis;
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m){ll res=1;while(n){if(n&1)res=(res*x)%m;n>>=1;x=((x%m)*(x%m))%m;}return res;}
inline bool ispow2(ll x){ return x && (!(x&(x-1)));}
inline ll gcd(ll x, ll y){ pll p{x,y}; while(p.ss) p={p.ss,p.ff%p.ss}; return p.ff;}

/////////////////// MAIN STARTS //////////////////////////////////
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

ll n,m; cin>>n>>m;
ll v[50]; v[0]=1;
for(int i=1;i<50;++i){
  v[i]=(((v[i-1]*(n+i-1))%MOD)*mexp(i,MOD-2,MOD))%MOD;
}
ll ans=1;
for(int i=2;i*i<=m;++i){
  ll f=0; while(m%i==0){++f; m/=i;}
  ans=(ans*v[f])%MOD;
}
if(m!=1) ans=(ans*n)%MOD;
cout<< ans <<'\n'; 


#ifdef DEBUG
auto diff=chrono::system_clock::now()-tStart;
cerr<<"\nExecution time: "<<chrono::duration<dd,milli>(diff).count()<<" ms.\n";
#endif
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n,m;
	cin>>n;
	vector<int>out(2*n);
	rep(i,2*n)out[i]=i+1;
	cin>>m;
	while(m--){
		int a;cin>>a;
		vector<int>tmp;
		if(!a){
			rep(i,n){
				tmp.pb(out[i]);
				tmp.pb(out[i+n]);
			}
		}else{
			loop(i,a,2*n)tmp.pb(out[i]);
			rep(i,a)tmp.pb(out[i]);
		}
		out=tmp;
	}
	rep(i,2*n)cout<<out[i]<<endl;
	
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;

ll dp[100010][13];
int main()
{

    string s;
    cin >> s;
    
    long long mod = 1e9 + 7;
    dp[0][0] = 1;
    for (int i = 0; i < s.size(); i++)
    {
        bool flag = false;
        if (s[i] == '?')
            flag = true;
        
            for (int j = 0; j < 10; j++)
            {   
                if(!flag && s[i]-'0'!=j)
                    continue;
                for (int k = 0; k < 13; k++)
                {
                    dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
                }
            }
                //更新後のmod
                for (int j = 0; j < 13; j++)
                    dp[i + 1][j] %= mod;
    }
    cout << dp[s.size()][5] << endl;

    return 0;
}

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

using namespace std;

string s;
vector<char> v;

int main() {
	cin >> s;
	for(int i = 0; i < s.length(); i++) {
		if (s[i] != 'B') v.push_back(s[i]);
		else if (v.size()) v.pop_back();
	}
	for(int i = 0; i < v.size(); i++) {
		cout << v[i];
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

int main(){
	ll n, x;
	cin >> n >> x;
	ll ans = n;
	ll l = n-x;
	while(x){
		ans += x*((l-1)/x)*2;
		if(l%x == 0)ans+=x;
		ll L = l;
		l = x;
		x = L%x;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <math.h> // sqrt()
#include <iomanip>
#define rep(i , n) for (int i = 1; i <= (int)(n); i++)
#define repz(i , n) for (int i = 0; i < (int) n; i++)
#define repi(i , r, n) for (int i = r; i <= (int)(n); i++)
#define repd(i , r, n) for (int i = r; i >= (int)(n); i--)


using namespace std;

bool check( int biti , int x){
    bool ok = true;
    while(x > 0) {
        if(( biti >> (x % 10) ) & 1) ok = false;
        x /= 10;
    }
    return ok;
}

int main(){
    int n , k, var;
    cin >> n >>k;
    int bit = 0;
    rep(i , k) {
        cin >> var;
        bit += ( 1 << var);
    }
    // inside bit if 1, unusable
   for ( int i = n ; i < 100 * n ; i++){
       if (check( bit , i ) ){
           cout << i << endl;
           return 0;
       }
       else
           continue;
   }

}

Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Pranay2516
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int s = in.nextInt(), w = in.nextInt();
            out.println(w >= s ? "unsafe" : "safe");
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 32448
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int n, h, w;
  cin >> n >> h >> w;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a >= h && b >= w) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
# ABC 113 D
MOD = 7 + 10**9 
H, W, K = map(int,input().split())
dp = [[0 for k in range(W)] for l in range(H+1)]

dp[0][0] = 1
for i in range(H):
    for j in range(W):
        for k in range(1<<(W-1)):
            f = 1
            for l in range(W-2):
                if (k>>l)&1 and (k>>(l+1))&1:
                    f = 0
            if f:
                if 0<j and (k>>(j-1))&1:
                    dp[i+1][j-1] += dp[i][j]
                    dp[i+1][j-1] %= MOD
                elif j <= W-2 and (k>>j)&1:
                    dp[i+1][j+1] += dp[i][j]
                    dp[i+1][j+1] %= MOD
                else:
                    dp[i+1][j] += dp[i][j]
                    dp[i+1][j] %= MOD

print(dp[H][K-1])


Measured memory_bytes: 46572
def examB():
    A, B = LI(); St = S()
    nums = list(map(str, range(10)))
    ans = "Yes"
    if St[A] == "-":
        for s in St[:A] + St[A + 1:]:
            if s not in nums:
                ans = "No"
                break
    else:
        ans = "No"
    print(ans)


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


Measured memory_bytes: 38384
N=int(input())
H=list(map(int,input().split()))	

h1=H[0]
ret=0
count=0
for i,h in enumerate(H[1:]):
  if h1>=h:
    count+=1
    if ret<count:
      ret=count
  else:
    count=0
  h1=h
    
print(ret)

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

int main()
{
    string S;
    cin >> S;

    vector<int> A(S.size() + 1, 0);
    for (int i = 0; i < S.size(); i++)
    {
        if (S.at(i) == '<')
        {
            A.at(i + 1) = max(A.at(i + 1), A.at(i) + 1);
        }
    }

    for (int i = S.size() - 1; i >= 0; i--)
    {
        if (S.at(i) == '>')
        {
            A.at(i) = max(A.at(i), A.at(i + 1) + 1);
        }
    }

    long ans = 0;
    rep(i, A.size())
    {
        ans += A.at(i);
    }

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

Measured memory_bytes: 5808
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

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

    }
    sort( a, a + n );
    cout << a[n / 2] - a[n / 2 - 1] << endl;
    return 0;
}


Measured memory_bytes: 640
N,K = map(int,input().split())
A = list(map(int,input().split()))

def func(A,X):
    out = 0
    for i in A:
        if i^X > i:
            out += 1
        else:
            out -= 1
    return (out > 0)
X = [0]
i = 1
while i <= K:
    if  func(A,i):
        X.append(i)
    i*=2

hoge = 0
X.reverse()
for i in X:
    if hoge + i <= K:
        hoge += i

ans = 0
for i in A:
    ans += i^hoge

print(ans) 

Measured memory_bytes: 14836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#define MP make_pair
#define VI vector<int>
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

const ll MaxN=1e5+5;
const ll MOD=1000000007;
const ll INF=ll(1e18);

ll n;
ll d[MaxN];
ll l,r;
void init(){
	cin>>n;
	REP(i,n) cin>>d[i];
}

void build(){

}

void sol(){
	l=r=2;
	for(int i=n-1;i>=0;i--){
		if(l%d[i]==0||l/d[i]*d[i]+d[i]<=r){
			l=((l+d[i]-1)/d[i])*d[i];
			r=(r/d[i])*d[i]+d[i]-1;
		}
		else{
			cout<<-1<<endl;
			return;
		}
	}
	cout<<l<<' '<<r<<endl;
}

int main(){
	IOS();
	init();
	build();
	sol();
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
 
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  NodePointer pre = t->prev, nex = t->next;
  pre->next = nex;
  nex->prev = pre;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer tmp = nil->prev;
  nil->prev = tmp->prev;
  deleteNode(tmp);
}

void delete(int key){
  /* your code */
  NodePointer cur = nil->next;

  while(1){
    if(cur==nil) break;
    if(cur->key == (unsigned int)key){
      deleteNode(cur);
      break;
    }
    cur = cur->next;
  }
}


void insert(int key){
  NodePointer i;
  i = malloc(sizeof(struct node));
  i->key = key;

  
  i->prev = nil;
  i->next = nil->next;
  nil->next->prev = i;
  nil->next = i;
  if(nil->prev == nil) nil->prev = i;
}

int main(){
  int key, a, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &a);
  init();
  for ( i = 0; i < a; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



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

using namespace std;

int main() {
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int r=0;
    for(int i=0; i<=a; i++) for(int j=0; j<=b; j++) for(int k=0; k<=c; k++) {
        if(500*i+100*j+50*k==x) r++;
    }
    cout << r << endl;

}

Measured memory_bytes: 256
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    // #pragma GCC optimize("Ofast")
    using namespace std;
    //library
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define F first
    #define S second
    #define pb push_back
    #define mkp make_pair
    #define int long long
    #define ld long double
    //scankar
    #define sz(x) (int)(x).size()
    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    typedef map<int,int> mii;
    typedef map<int,bool> mib;
    typedef map<char,int> mci;
    typedef map<string,int> msi;
    
    const int INF = 1e18L + 5;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    //direction
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ D $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;
    //debugger

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    int sum,x,ptr;
    vector<int> v;

    void solve()
    {
        cin>>n;
        fo(i,0,n)
        {
            cin>>x;
            v.pb(x);
        }
        sort(rall(v));

        fo(i,1,n)
        {
            if(i%2)
            sum+=v[ptr++];
            else
                sum+=v[ptr];
        }
        cout<<sum<<endl;
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          THE GAME STARTS HERE                             //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        
        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

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

int main()
{
	string arr[]= {"Sunny","Cloudy","Rainy"};
	
	
	string s;
	cin>>s;
	
	if(s==arr[0])
	cout<<arr[1];
	
	else if(s==arr[1])
	cout<<arr[2];
	
	else if(s==arr[2])
	cout<<arr[0];
}

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

using namespace std;

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

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

int main() {

    string s;
    while(getline(cin, s), s != ".") {
        stack< char > cir;
        bool judge = true;
        for(int i = 0; i < s.size(); i++) {
            if(s[i] == '(' || s[i] == '[') cir.push(s[i]);
            else if(s[i] == ')' || s[i] == ']') {
                if(cir.empty()) judge = false;
                else {
                    if(s[i] == ')' && cir.top() != '(') judge = false;
                    if(s[i] == ']' && cir.top() != '[') judge = false;
                    cir.pop();
                }
            }
        }
        cout << (judge && cir.empty() ? "yes" : "no") << endl;
    }
}

Measured memory_bytes: 1176
#include <iostream>

using namespace std;

int main()
{
  	int N;
  	cin >> N;
  	int n = N, a = n % 10;
  	for(; n > 0; ){
      	n /= 10;
      	a += n % 10;
    }
  	if(N % a == 0){
      	cout << "Yes";
    }else{
      	cout << "No";
    }
  	return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
#pragma GCC optimize ("O2")
typedef long long LL;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
void OUT(LL x){if(x<0)putchar('-'),x=-x;if(x>=10)OUT(x/10);putchar(x%10+48);}
int main(void)
{
  static int div,K=1;int N=IN();static LL a=0;
  while(K<=N){div=N/(N/K)+1;a+=1ll*(div-K)*(K+div-1)*(N/K)*(N/K+1)/4;K=div;}
  return OUT(a),0;
}

Measured memory_bytes: 1528