akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

void ok(){
    cout << "Yes" << endl;
    exit(0);
}

void ng(){
    cout <<  "No" << endl;
    exit(0);
}
Int n;
P p[110000];
vector<Int> a, b;
map<Int, Int> goal;

int main(){
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> p[i].second;
        a.push_back(p[i].second);
    }
    for(int i = 0;i < n;i++){
        cin >> p[i].first;
        b.push_back(p[i].first);
    }
    sort(p, p + n);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    bool strict = true;
    for(int i = 0;i < n;i++){
        if(a[i] > b[i])ng();
        if(i > 1 && a[i] <= b[i-1])strict = false;
    }
    if(!strict)ok();
    for(int i = 0;i < n;i++){
        goal[a[i]] = i;
    }
    int now = 0;
    int cnt = 0;
    while(true){
        cnt++;
        now = goal[p[now].second];
        if(now == 0)break;
    }
    if(cnt == n)ng();
    else ok();
    return 0;
}

Measured memory_bytes: 9708
#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>;
using vi = vector<ll>;
using vv = vector<vi>;
//const int MOD = 1000000007;
const int MOD = 998244353;
const int INF = 1001001001;
const ll LINF = 1001001001001;



int main(){
    
    int n;cin>>n;
    vv faclist(19, vi (19, 0));
    
    rep(i,n){
        string a;
        cin>>a;
        
        ll anum = 0;
        int dot = 0;
        
        rep(j,a.size()){
            if(a[j]=='.'){
                dot = j+1 - a.size();
            }
            else{
                anum *= 10;
                anum += a[j]-'0';
            }
        }
        int fac2 = dot, fac5 = dot;
        
        rep(j,19){
            if(anum%2)break;
            else{
                anum /= 2;
                fac2++;
            }
        }
        rep(j,19){
            if(anum%5)break;
            else{
                anum /= 5;
                fac5++;
            }
        }
        
        faclist[min(18,fac2+9)][min(18,fac5+9)]++;
    }
    
    vv acclist = faclist;
    
    
    rep(i,19){
        for(int j=17; j>=0; j--){
            acclist[i][j] += acclist[i][j+1];
        }
    }
    rep(j,19){
        for(int i=17; i>=0; i--){
            acclist[i][j] += acclist[i+1][j];
        }
    }
    
    ll ans = 0;
    
    rep(i,19)rep(j,19){
        if(!faclist[i][j])continue;
        
        if(i>8 && j>8)ans += faclist[i][j] * (acclist[18-i][18-j]-1);
        else ans += faclist[i][j] * acclist[18-i][18-j];
    }
    
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);

ll get_min(ll h, ll w) {
  ll y = INF;
  for (int x = 1; x <= w-2; x++) {
    ll s1 = x * h;
    ll s2, s3;
    if (w-x % 2 == 0) {
      s2 = s3 = h * ((w-x) / 2);
    } else {
      s2 = h * ((w-x) / 2);
      s3 = h * (1 + (w-x) / 2);
    }

    ll t2, t3;
    if (h % 2 == 0) {
      t2 = t3 = (h / 2) * (w-x);
    } else {
      t2 = (h / 2) * (w-x);
      t3 = (1 + h / 2) * (w-x);
    }

    ll d1 = max(s1, max(s2, s3)) - min(s1, min(s2, s3));
    ll d2 = max(s1, max(t2, t3)) - min(s1, min(t2, t3));
    y = min(y, min(d1, d2));
  }

  return y;
    
}

int main() {
  ll H, W; cin >> H >> W;
  if (H % 3 == 0 || W % 3 == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (H == 2 && W == 2) {
    cout << 1 << endl;
    return 0;
  }

  ll ans = min(get_min(H, W), get_min(W, H));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int d, w;		/* d: ???????\\??????, w:????????? */
	int rectangle[10][10];	/* ????????§?????? */
	int left, right;		/* ?±??????§??????????±??????????????????°?????? */
	int top, bottom;		/* ?±??????§??????????±??????????????????°????\\??????*/
	int i, j;
	int min_case = 100, max_lake = 0;	/* min_case: ?±???£????¨???????????°????, max_lake: ?±???????????????????????¨???? */
	int max_volume = 0;		/* ??????: ?±???????????????¨?????§???????????§????????? */
	int volume = 0;			/* ?±?????????? */

	while (1) {
		/* ??\??? */
		scanf("%d %d", &d, &w);
		if (d == 0 && w == 0)
			break;
		else {
			for (j = 0; j < d; j++) {
				for (i = 0; i < w; i++) {
					scanf("%d", &rectangle[i][j]);
				}
			}

			/* ?±??????§??????????±?????????¨??°???  ??°?????????B_LakeCreate?????§ */
			for (top = 0; top <= d - 3; top++) {
				for (bottom = top + 3; bottom <= d; bottom++) {
					for (left = 0; left <= w - 3; left++) {
						for (right = left + 3; right <= w; right++) {

							/* ?±???????????????????????????¢???????±??????????????±??????? */
							/* 1. ?±??????????????°????????±??????? */
							for (i = left; i < right; i++) {
								if (min_case > rectangle[i][top])
									min_case = rectangle[i][top];
								/*printf("top: i = %d, data = %d, %d\n", i, rectangle[i][top], min_case);*/
								if (min_case > rectangle[i][bottom - 1])
									min_case = rectangle[i][bottom - 1];
								/*printf("bottom: i = %d, data = %d, %d\n", i, rectangle[i][bottom - 1], min_case);*/
							}
							for (j = top + 1; j < bottom - 1; j++) {
								if (min_case > rectangle[left][j])
									min_case = rectangle[left][j];
								/*printf("left: j = %d, data = %d, %d\n", j, rectangle[left][j], min_case);*/
								if (min_case > rectangle[right - 1][j])
									min_case = rectangle[right - 1][j];
								/*printf("right: j = %d, data = %d, %d\n", j, rectangle[right - 1][j], min_case);*/
							}

							/* 2. ?±???????????¨????????????§???????±??????? */
							for (j = top + 1; j < bottom - 1; j++) {
								for (i = left + 1; i < right - 1; i++) {
									if (max_lake < rectangle[i][j])
										max_lake = rectangle[i][j];
									/*printf("i,j = %d,%d, data = %d, max = %d\n", i, j, rectangle[i][j], max_lake);*/
								}
							}

							/* 3. ?±???£???????°??????¨?±?????¨????????????§???????????? */
							if (max_lake >= min_case) {
								max_lake = 0;
								min_case = 100;
								continue;
							}
							/* 4. ?±??????????????±??????? */
							else {
								for (j = top + 1; j < bottom - 1; j++) {
									for (i = left + 1; i < right - 1; i++) {
										volume += (min_case - rectangle[i][j]);
									}
								}
							}

							/* ?±??????????????????? */
							if (max_volume < volume)
								max_volume = volume;


							/* ????????? */
							max_lake = 0;
							min_case = 100;
							volume = 0;
						}
					}
				}
			}

			/* ?????? */
			printf("%d\n", max_volume);

			/* ????????? */
			max_volume = 0;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<string.h>

#define M 1000003
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return (key%M); }
int h2(int key){ return (1+(key%(M-1))); }

int find(char str[]){
  int i=0;
  int j;
  while(1){
    j=(h1(getKey(str))+i*h2(getKey(str)))%M;
    if(strcmp(H[j],str)==0)
      return j;
    else if(H[j][0]=='\0' || i>=M)
      return 0;
    i++;
  }
  return 0;
}

int insert(char str[]){
  int i=0;
  int j;
  while(i!=M){
    j=(h1(getKey(str))+i*h2(getKey(str)))%M;
    if(H[j][0]=='\0'){
      strcpy(H[j],str);
      return j;
    }
    i++;
  }
  return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
  
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);
	
	if ( com[0] == 'i' ){
      insert(str);
	} else {
      if (find(str)){
		printf("yes\n");
      } else {
		printf("no\n");
      }
	}
  }
  
  return 0;
}



Measured memory_bytes: 15420
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f;
const int MOD = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  ll mn = 1e9;
  for (int i = 0; i < (1 << n); i++) {
    int bits[n];
    ll x = i, ori = 1;
    for (int j = 0; j < n; j++)
      bits[j] = x & 1, x >>= 1;
    for (int j = 0; j < n; j++) {
      // cout << bits[j] << ' ';
      if (bits[j])
        ori += k;
      else
        ori *= 2;
    }
    // cout << endl;
    mn = min(ori, mn);
  }
  cout << mn << endl;
}

Measured memory_bytes: 256
//	ZapZu's code hohoho
//	#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define dfs_black 1
#define dfs_white -1
#define pr pair
#define vt vector
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef double db;
typedef long long li;
typedef long double ld;

typedef pr<int, int> ii;
typedef pr<ld,ld> dd;

typedef vt<int> vi;
typedef vt<li> vli;
typedef vt<ld> vld;
typedef vt<ii> vii;

typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, char> mic;

typedef set<int> s_i;
typedef set<char> s_c;

const int MOD = 1e9+7;
const li INF = 1e18;
const ld PI = 4*atan((ld)1);
li d[305][305];
signed main()
{
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
int n;
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
		{
			cin>>d[i][j];
		}
	}
	li ans=0;
	for(int i=1; i<=n; i++)
	{
		for(int j=i+1; j<=n; j++)
		{
			bool c=1;
			for(int k=1; k<=n; k++)
			{
				if(k==i or k==j) continue;
				if(d[i][k]+d[k][j]<d[i][j])
				{
					cout<<-1;
					return 0;
				}
				if(d[i][k]+d[k][j]==d[i][j])c=0;
			}
			ans+=c*d[i][j];
		}
	}
	cout<<ans;
}




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

int main() {
	int N;
	cin >> N;
	double ans = 0;
	for (int i = 0; i < N; i++) {
		double x;
		string u;
		cin >> x >> u;
		if (u == "JPY") ans += x;
		else ans += x * 380000.0;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')



X = I()
for a in range(-1000, 1001):
    for b in range(-1000, 1001):
        if a ** 5 - b ** 5 == X:
            print(a, b)
            exit(0)

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection)  (collection).begin(), (collection).end()		// begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)				// repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)			// repeat reverse

#endif

void Solve(ll& a, ll& b, ll& ans)
{
	ans += min(a, b);
	if (min(a, b) == b)
	{
		a -= b;
		b = 0;
	}
	else
	{
		b -= a;
		a = 0;
	}
}

int main(void)
{
	ll n; cin >> n;
	vector<ll> a(n+1);
	vector<ll> b(n);

	rep(i, 0, n + 1)
		cin >> a[i];
	rep(i, 0, n)
		cin >> b[i];
	
	ll ans = 0;
	rep(i, 0, n)
	{
		Solve(a[i], b[i], ans);
		Solve(a[i+1], b[i], ans);
	}

	cout << ans;
	return 0;
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int n, m, k; cin >> n >> m >> k;
  vector<int> d(m);
  map<int, int> mp;
  for(int i=0;i<m;++i) {
    cin >> d[i];
    d[i]--;
    mp[d[i]] = i + 1;
  }

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

  vector<int> dp(1<<m, INF);
  dp[(1<<m) - 1] = 0;
  queue<int> que;
  que.push((1<<m)-1);
  while(!que.empty()) {
    for(int i=0;i<k;++i) {
      int now = que.front(), next = 0;
      for(int j=0;j<m;++j) {
        if(now & 1) {
          if(mp[v[d[j]][i]]) {
            next |= (1 << (mp[v[d[j]][i]] - 1));
          }
        }
        now >>= 1;
      }
      if(dp[next] == INF) {
        que.push(next);
      }
      dp[next] = min(dp[next], dp[que.front()] + 1);
    }
    que.pop();
  }
  cout << dp[0] << endl;
}



Measured memory_bytes: 3480
#include <bits/stdc++.h>
#define t(w) int w; cin>>w; while(w--) 
typedef long long int ll; 
using namespace std;

void solve(){
	ll n;
	vector<ll> o,e;
	cin>>n;
	for(ll i=0;i<2*n;i++){
		ll a;
		cin>>a;
		if(a%2==0)
		e.push_back(i);
		else
		o.push_back(i);
	}
	if(e.size()%2!=0){
		e.pop_back();
		o.pop_back();
	}
	else if(o.size()%2==0){
		e.pop_back();
		e.pop_back();
	}
	
	for(ll i=0;i<e.size();i=i+2)
	cout<<e[i]+1<<" "<<e[i+1]+1<<endl;
	for(ll i=0;i<o.size();i=i+2)
	cout<<o[i]+1<<" "<<o[i+1]+1<<endl;
}
void solve1(){
	char a;
	cin>>a;
	if(65<=(int)a && (int)a<=90)
	cout<<'A'<<endl;
	else if(97<=(int)a && (int)a<=122)
	cout<<'a';
//	cout<<(int)'A'<<" "<<(int)'Z'<<endl<<(int)'a'<<" "<<(int)'z';
}
int main(){
	solve1();
	return 0;
}


Measured memory_bytes: 3624
//B
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	string s;
	cin >> s;
	bool ok = 1;
	for(int i = 0;i < s.size()/2;i++){
		if(s[i] != s[s.size()-1-i])ok = 0;
	}
	if(ok){
		string u = s.substr(0,((int)s.size()-1)/2);
		for(int i = 0;i < u.size()/2;i++){
			if(u[i] != u[u.size()-1-i])ok = 0;
		}
		u = "";
		for(int i = (s.size()+3)/2-1;i < s.size();i++)u += s[i];
		for(int i = 0;i < u.size()/2;i++){
			if(u[i] != u[u.size()-1-i])ok = 0;
		}
	}
	if(ok)cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

INF = float("inf")


def main():
    H, N = map(int, input().split())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    dp = [INF] * (H + max(A))
    dp[0] = 0
    for h in range(H):
        for a, b in zip(A, B):
            if dp[h]+b < dp[h+a]:
                dp[h+a] = dp[h]+b
    ans = min(dp[H:])
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<string> s(n, "");
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
	}

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

	long long counter = 0;
	int subcount = 0;
	int i = 0;
	int j = 1;
	while (1) {
		subcount = 0;
		j = 1;
		if (s[i] == s[i+j]&& i+j<n) {
			while (1) {
				if (i + j >= n) { break; }
				if (s[i] == s[i + j] && i + j < n) {
					j++;
				}
				else { break; }
			}
			counter += (long long)j*(j-1)/2 ;
			i += j-1;
			if (i >= n) { break; }
		}
		i++;
		if (i >= n - 1) { break; }
	}
	cout << counter << endl;
}

Measured memory_bytes: 7296
import sys

n = int(input())
array = [int(x) for x in input().split()]

cnt = 1
if n ==1:
    print(cnt)
    exit()

tmp = array.pop(0)
tmp2 = array.pop(0)
mode = "plus" if tmp2 > tmp else "minus" if tmp2 != tmp else "equal"
tmp = tmp2

for i in array:
    if tmp < i:
        if mode == "minus":
            cnt += 1
            mode = "equal"
        elif mode == "equal":
            mode = "plus"
    elif tmp > i:
        if mode == "plus":
            cnt += 1
            mode = "equal"
        elif mode == "equal":
            mode = "minus"
    tmp = i
print(cnt)

Measured memory_bytes: 14224
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

const int INF = 1 << 30;

struct LazySegmentTree {
private:
    int n;
    vector<int> node, lazy;
    vector<bool> lazyFlag;

public:
    LazySegmentTree(vector<int> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, INF);
        lazyFlag.resize(2*n-1, false);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }

    void lazyEvaluate(int k, int l, int r) {
        if(lazyFlag[k]) {
            chmin(node[k], lazy[k]);
            if(r - l > 1) {
                if (chmin(lazy[k*2+1], lazy[k])) {
                    lazyFlag[k*2+1] = true;
                }
                if (chmin(lazy[k*2+2], lazy[k])) {
                    lazyFlag[k*2+2] = true;
                }
            }
            lazyFlag[k] = false;
        }
    }

    void update(int a, int b, int x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return;
        if(a <= l && r <= b) {
            if (chmin(lazy[k], x)) {
                lazyFlag[k] = true;
            }
            lazyEvaluate(k, l, r);
        }
        else {
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }

    int find(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        lazyEvaluate(k, l, r);
        if(b <= l || r <= a) return INF;
        if(a <= l && r <= b) return node[k];
        int vl = find(a, b, 2*k+1, l, (l+r)/2);
        int vr = find(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, Q;
    cin >> N >> Q;
    LazySegmentTree col_seg(vector<int>(N - 1, N - 1)), row_seg(vector<int>(N - 1, N - 1));
    int query, X;
    ll ans = (N - 2) * (N - 2);
    rep(i, 0, Q) {
        cin >> query >> X;
        if (query == 1) {
            ll max_pos = col_seg.find(X - 1, X);
            ans -= max_pos - 1;
            row_seg.update(0, max_pos, X - 1);
        } else {
            ll max_pos = row_seg.find(X - 1, X);
            ans -= max_pos - 1;
            col_seg.update(0, max_pos, X - 1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12232
#include <stdio.h>

int main(void){
    int alphabet[26] = {0};
    int c, i;
    
    do{
        c = getchar();
        alphabet[c-'a'] = 1;
    }while(c >= 'a' && c <= 'z');
    
    for(i=0; i<26; i++){
        if(alphabet[i] == 0){
            printf("%c\n", i+'a');
            return 0;
        }
    }
    
    printf("None\n");
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

string S;

int main(){
	cin>>S;

	if(S[2]==S[3] && S[4]==S[5]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#define DEB2(X) cout<<X<<" ";
#else
#define DEB(X) {}
#define END {}
#define DEB2(X) {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
string S;
int A[100010];
bool F[100010];

void run(int a,int b){
	REP(i,N){
		A[i]=0;
	}
	A[0]=a,A[1]=b;
	for(int i=2;i<N;i++){
		int P=A[i-2];
		int Q=F[i-1];
		if(A[i-1]==1){
			Q=!Q;
		}
		if(P==0&&Q==0){
			A[i]=0;
		}
		else if(P==0&&Q==1){
			A[i]=1;
		}
		else if(P==1&&Q==0){
			A[i]=1;
		}
		else{
			A[i]=0;
		}
	}
}

void solve(int a,int b){
	run(a,b);
	vector<int> v;
	v.push_back(A[N-1]);
	bool flag=true;
	REP(i,N){
		v.push_back(A[i]);
	}
	v.push_back(A[0]);
	for(int i=1;i<=N;i++){
		int p=i-1;
		if(v[i]==0){
			if(F[p]==1&&v[i-1]==v[i+1]){
				flag=false;
			}
			if(F[p]==0&&v[i-1]!=v[i+1]){
				flag=false;
			}
		}
		else{
			if(F[p]==0&&v[i-1]==v[i+1]){
				flag=false;
			}
			if(F[p]==1&&v[i-1]!=v[i+1]){
				flag=false;
			}
		}
	}
	if(flag==true){
		REP(i,N){
			if(A[i]==0){
				cout<<"S";
			}
			else{
				cout<<"W";
			}
		}
		cout<<endl;
		exit(0);
	}
}

signed main(){
	cin>>N>>S;
	REP(i,N){
		if(S[i]=='x')F[i]=1;
	}
	solve(0,0);
	solve(0,1);
	solve(1,0);
	solve(1,1);
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 3216
#include <iostream>
const int64_t MOD=1000000007;
int main(){
  int64_t n;
  std::cin >> n;
  int64_t n_one_fixed = 1;
	int64_t n_two_fixed = 0;
	int64_t pow_10 = 10;
  for(int i=2;i<=n;++i) {
    int64_t new_one_fixed = (pow_10 + 9*n_one_fixed) % MOD;
    int64_t new_two_fixed = (2*n_one_fixed + 8*n_two_fixed)% MOD;
    n_one_fixed = new_one_fixed;
    n_two_fixed = new_two_fixed;
    pow_10 = (pow_10 * 10) % MOD;
  }
  std::cout << n_two_fixed;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int L, R;
  cin >> L >> R;

  int a = L / 2019;
  int b = (a + 1) * 2019;
  a *= 2019;

  if (b <= R || L <= a) {
    cout << 0;
  }
  else {
    int result = 2019;
    FOR(i, L, R) {
      FOR(j, L + 1, R + 1) {
        chmin(result, (i64)i * j % 2019);
      }
    }
    cout << result;
  }
}
#endif


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

int main() {
	int n,m,k,i,j,ans=0;
	cin >> n >> m >> k;
	vector<long> a(n),b(m);
	for(i=0; i<n; i++){
		cin >> a[i];
	}
	for(j=0; j<m; j++){
		cin >> b[j];
	}
	
	vector<long> l(n+1,0),r(m+1,0);
	for(i=0; i<n; i++){
		l[i+1]=l[i]+a[i];
	}
	for(j=0; j<m; j++){
		r[j+1]=r[j]+b[j];
	}
	
	j=m;
	for(i=0; i<=n; i++){
		while(l[i]+r[j]>k && j>=0){
			j--;
		}
		if(j>=0){
			ans=max(ans,i+j);
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {

    int N, Y;
    cin >> N >> Y;

    bool ok = false;
    int ansa, ansb, ansc;
    for (int a = 0; a <= 2000; a++) {
        if ((Y - 1000*N - 9000*a) % 4000 != 0) {
            continue;
        }
        int b = (Y - 1000*N - 9000*a) / 4000;
        int c = N - a - b;
        if (10000*a + 5000*b + 1000*c == Y && b>=0 && c>=0) {
            ansa = a;
            ansb = b;
            ansc = c;
            ok = true;
            break;
        }
    }
    if (ok) {
        cout << ansa << " " << ansb << " " << ansc << endl;
    } else {
        cout << -1 << " " << -1 << " " << -1 << endl;
    }
}

signed main() {
    solve();
}


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

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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for(int i = 1; i <= n; i++) {
    ans += i * calc(n/i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3584
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	long long sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
		if(i%3!=0&&i%5!=0)
			sum+=i;
	cout<<sum;
	return 0;
}


Measured memory_bytes: 3636
def resolve():
    s = [int(i) for i in input()]
    p_cnt = 0

    p = 2019

    s = s[::-1]
    div_dic = dict(zip(range(p), [0] * p))
    tmp = 0

    for i in range(len(s)):
        tmp += s[i] * pow(10, i, p)
        tmp %= p
        div_dic[tmp] += 1

    for v in div_dic.values():
        p_cnt += v * (v - 1)
    p_cnt //= 2
    p_cnt += div_dic.get(0)


    print(p_cnt)
    
resolve()

Measured memory_bytes: 12200
def intersect(a, b, c, d):
    if b < c or d < a:
        return -2, -1
    else:
        li = sorted([a, b, c, d])
        return li[1], li[2]
        
N, M = map(int, input().split())
LR = []
for _ in range(M):
    LR.append(tuple(map(int, input().split())))
    
a, b = LR[0]
for lr in LR:
    a, b = intersect(a, b, *lr)
    
ans = b-a+1
print(ans) if a > 0 else print('0')

Measured memory_bytes: 16616
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: usize,
        y: usize,
    }
    for i in 0..(x + 1) {
        if 2 * i + 4 * (x - i) == y {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  string s;
  cin >> s;
  int n = (int)(s.length());
  int i = 0,f = 1;
  while(f == 1 && i < n)
  {
      if(i % 2 == 0 &&  s[i] == 'L')f = 0;
      if(i % 2 == 1 &&  s[i] == 'R')f = 0;
      i++;
  }
  if(f == 1) cout <<"Yes\n";
  else cout << "No\n";
  return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
if N % 2:
    print(0)
    exit()

ans = 0
n = 10
while N >= n:
    ans += N//n
    n *= 5

print(ans)

# N = 40
# def get(i):
#     if i < 2:
#         return 1
#     return i * get(i-2)
#
# for i in range(N):
#     n = get(i)
#     # print(n)
#     k = n
#     m = 0
#     while n % 5 == 0:
#         m += 1
#         n //= 5
#     print(i, m, k)





Measured memory_bytes: 38256
//20190915
//Naru
#include<iostream>
using namespace std;

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  int* p = new int[N+1];
  for(int i=1; i<=N; i++) {
    p[i] = -Q + K;
  }
  for(int i=1; i<=Q; i++) {
    int A;
    cin >> A;
    p[A]++;
  }
  for(int i=1; i<=N; i++) {
    if(p[i] <= 0) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}


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

int main(){
  int H,W;
  cin >> H >> W;
  vector<string> vec(H);
  for(int i=0;i<H;i++){
    cin >> vec.at(i);
  }
  for(int i=0;i<W+2;i++){
    cout << "#";
  }
  cout << endl;
  for(int i=0;i<H;i++){
    cout << '#' << vec.at(i) << '#' << endl;
  }  
  for(int i=0;i<W+2;i++){
    cout << "#";
  }
  cout << endl;
}

Measured memory_bytes: 256
//0052
//nÌKæÌlÌöÌ0ÌÂð¦æ
#include<cstdio>
#include<climits>
using namespace std;

int main(void)
{
	int n;
	int canDiv5;
	int i, j;

	const int a[] = {5, 25, 125, 625, 3125, 15625, 78125, 390625, 1953125, 9765625,
		48828125, 244140625, 1220703125, INT_MAX, /*6103515625, 30517578125*/};

	while(scanf("%d", &n), n)
	{
		//µ©µAOOêÎ¦ÀÉoé¶á èÜ¹ñ©
		//http://www3.ocn.ne.jp/~fukiyo/math-qa/kaijou.htm
		canDiv5 = 0;
		for(i = 0; i < sizeof(a)/sizeof(a[0]); i++)
			canDiv5 += n/a[i];
		printf("%d\n", canDiv5);
	}
	return 0;
}

Measured memory_bytes: 0
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
V<ll> g1[100005],g2[100005];
map<P,bool> used;
V<int> c;
V<P> ans;
 void dfs(int cur,int par){
     for(int v:g2[cur]){
         if(v==par)continue;
         dfs(v,cur);
     }
     if(par!=-1){
         if(c[cur]%2==1){
             ans.emplace_back(cur,par);
             c[cur]++;
         }else{
             ans.emplace_back(par,cur);
             c[par]++;
         }
     }
 }
int main(){
    int n,m;
    cin>>n>>m;
    c.assign(n,0);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        g1[--a].push_back(--b);
        g1[b].push_back(a);
        used[P(a,b)]=true;
    }
    if(m%2){
        cout<<-1<<"\n";
        return 0;
    }
    queue<int> q;
    q.push(0);
    V<bool> visited(n,false);
    visited[0]=true;
    while(q.size()){
        int cur=q.front();
        q.pop();
        for(int v:g1[cur]){
            if(visited[v])continue;
            visited[v]=true;
            used[P(cur,v)]=false;
            used[P(v,cur)]=false;
            g2[cur].push_back(v);
            g2[v].push_back(cur);
            q.push(v);
        }
    }
    for(auto p:used){
        if(p.se){
            ans.push_back(p.fi);
            c[p.fi.fi]++;
        }
    }
    dfs(0,-1);
    for(int i=0;i<m;i++){
        cout<<ans[i].fi+1<<" "<<ans[i].se+1<<"\n";
    }
}

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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n, a, b;

int main() {
  cin >> n >> a >> b;
  cout << ((a + b) & 1 ? "Borys" : "Alice");
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
colors = {'R': 1, 'G' : 2, 'B' : 3}

def dkey(dict, val):
    for e in dict:
        if dict[e] == val:
            return e

sum = [[0] * (n+1) for i in range (3)]
for i in range (3):
    for j in range (n):
        if(s[j] == dkey(colors,i + 1)):
            sum[i][j + 1] = sum[i][j] + 1
        else:
            sum[i][j + 1] = sum[i][j]

ans = 0
for i in range (n-2):
    for j in range (i+1,n-1):
        if s[i] == s[j]:
            continue
        k = 6//(colors[s[i]]*colors[s[j]])
        ans += sum[k-1][n] - sum[k-1][j+1]
        if 2*j-i < n and s[2*j-i] == dkey(colors,k):
            ans -= 1
print(ans)

Measured memory_bytes: 74500
#include <stdio.h>
           
int main(void){
           
  int a,b,d,r;
  double f;
           
  scanf("%d %d",&a,&b);
  d = a / b;
  r = a % b;
  f = (double)a / b;
  printf("%d %d %.6f\n",d,r,f);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;


int main(){
int n;
  cin>>n;
  vec1(a,n);
  bool flag=true;
  
  for(auto x:a){
    if(x%2==1) continue;
    if(x%3==0 || x%5==0) continue;
    flag =false;
    break;
  }
if(flag) cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}

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

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

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= M; j++) {
            if (i * (M - j) + j * (N - i) == K) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#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() {
  ll n;
  cin >> n;
  vector<ll> a(n+1);
  vector<ll> b(n);
  rep(i,n) {
      cin >> b[i];
      a[b[i]]++;
  }
  ll ans=0;
  for (int i=1; i<n+1; i++) {
      if(a[i]<2) continue;
      ans+=a[i]*(a[i]-1)/2;
  }
  rep(i,n) {
      if(a[b[i]]<2) cout << ans << endl;
      else if(a[b[i]]==2) {
         
          cout << ans-1 << endl;
      }
      else {
          ll aans=ans-a[b[i]]*(a[b[i]]-1)/2+(a[b[i]]-1)*(a[b[i]]-2)/2;
          cout << aans << endl;
      }
  }
  return 0;
}


Measured memory_bytes: 5760
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

ans = 0
if n >= m:
    print(ans)
else:
    d = []
    for i in range(m - 1):
        d.append(x[i + 1] - x[i])
    d.sort()
    for i in range(m - n):
        ans += d[i]
    print(ans)

Measured memory_bytes: 56872
// Aizu 1131: Unit Fraction Partition
// 2017.10.24 bal4u@uu

#include <stdio.h>
#include <math.h>

#define EPS 1e-9
double tbl[12005];

int bsch(double v)
{
	int m, l = 0, r = 12001;

	while (l < r) {
		m = (l + r) >> 1;
		if (fabs(tbl[m] - v) <= EPS) return m;
		if (tbl[m] > v) l = m + 1; else r = m;
	}
	if (l <= 0) l = 1;
	return l;
}

int ans, a;

int gcd(int a, int b)
{
	int r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

void rec(double v, int k, int n, int aa)
{
	int i, l, r;

	if (n < 0 || aa > a) return;
	if (fabs(v) <= EPS) { ans++; return; }
	if (n == 0) return;

	l = bsch(v), r = bsch(v / n);
	if (k > l) l = k;
	if ((double)n/l + EPS < v) return;
	k = a / aa;
	if (r > k) r = k;
	for (i = l; i <= r; i++) rec(v - 1.0 / i, i, n - 1, aa*i);
}

int main()
{
	int p, q, n, i, l, r;
	double v;

	for (i = 1; i <= 12002; i++) tbl[i] = 1.0 / i;

	while (scanf("%d%d%d%d", &p, &q, &a, &n) && n > 0) {
//		i = gcd(p, q); p /= i, q /= i;
		v = (double)p / q;
		if (fabs(v-n) <= EPS) { puts("1"); continue; }
		if (v > n) { puts("0"); continue; }
		l = bsch(v), r = bsch(v / n);
		for (ans = 0, i = l; i <= r; i++) {
			rec(v - 1.0 / i, i, n - 1, i);
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1808
#include<bits/stdc++.h>
using namespace std;
const int LIM=1e6;
bool Ban[LIM+10];
int N,A[LIM+10];
int main(){
    cin>>N;
    for(int i=1;i<=N;i++)
        cin>>A[i];
    sort(A+1,A+1+N);
    
    int Cnt=0;
    for(int i=1;i<=N;i++)
        if(!Ban[ A[i] ]){
            Cnt+=(A[i]!=A[i+1]);
            for(int j=A[i];j<=LIM;j+=A[i])
                Ban[j]=1;
        }
    cout<<Cnt;
    return 0;
}

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


int main() {
    int k;
    long result = 0;
    cin >> k;
    int** table = (int**) malloc(sizeof(int*) * k);
    for (int i = 0; i < k; i++) {
        table[i] = (int*) malloc(sizeof(int) * k);
        for (int j = 0; j < k; j++)
            table[i][j] = __gcd(i + 1, j + 1);
    }
    for (int i = 0; i < k; i++)
        for (int j = 0; j < k; j++)
            for (int l = 0; l < k; l++)
                result += table[table[i][j] - 1][l];
    cout << result;
    return 0;
}

Measured memory_bytes: 3748
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace List_of_Top_3_Hills
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] hills = new int[10];

            for (int i = 0;i < hills.Length; i++)
            {
                hills[i] = int.Parse(Console.ReadLine());
            }

            Array.Sort(hills);
            Array.Reverse(hills);

            for (int j = 0; j < 3; j++)
            {
                Console.WriteLine(hills[j]);
            }
            
        }
    }
}

Measured memory_bytes: 5756
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define IOS ios::sync_with_stdio(false)
void solve() {
	string s, t;
	cin >> s >> t;
	int ns = s.size();
	int nt = t.size();
	int ans = 0, num = 0;
	for (int i = 0; i < ns - nt + 1; ++i) {
		num = 0;
		for (int j = 0; j < nt; ++j) {
			if (s[i + j] == t[j]) {
				num++;
			}
		}
		ans = max(ans, num);
	}
	cout << nt - ans << endl;
}
int main() {
	solve(); 
	return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void) {
	// your code goes here
	int n,a[100],i,j,kosuu=0,d;
	scanf("%d",&n);
	for(i=1;i<=n;i=i+2){
		d=0;
		for(j=1;j<=i;j++){
			if(i%j==0) d++;
		}
		if(d==8) kosuu++;
	}
	printf("%d\n",kosuu);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[1000];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    printf("%d",a[n-1]-a[0]);
    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(" ").map { |e|e.to_i  }
bc = []

q = gets.chomp.to_i
q.times do
  bc << gets.chomp.split(" ").map { |e|e.to_i  }
end

table = a.tally
table.default = 0
sum = a.sum

bc.each do |b, c|
  sum += table[b] * (c - b)
  table[c] += table[b]
  table[b] = 0
  puts sum
end

Measured memory_bytes: 27220
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 a, b;
  cin >> a >> b;
  i64 ans;
  if (a < 6) ans = 0;
  else if (a <= 12) ans = b / 2;
  else ans = b;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int S,s,m,h;
    scanf("%d",&S);
    h = S / 3600;
    S = S % 3600;
    m = S / 60;
    S = S % 60;
    s = S;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}



Measured memory_bytes: 2064
"""
def bs(num_array, max_element, min_element):
    from collections import deque
    if(num_array == max_element - min_element + 1):
        que = deque(deque([i for i in range(min_element, max_element+1, 1)]))
        return que
    else:        
        # If min_element is not used
        que = deque([deque([])])
        que.extend(bs(num_array, max_element, min_element + 1))
        # IF min_element is used
        subset_yes = bs(num_array-1, max_element, min_element + 1)
        for e in subset_yes:
            e.appendleft(min_element)
        
        que.extendleft(subset_yes)
        return que
"""
def solve(S):
    from itertools import combinations
    from collections import deque
    n = len(S)
    answer = 0
    for i in range(n):
        for item in combinations(list(range(1, n, 1)), i):
            char_list = [c for c in S]
            que = deque(item)
            while que:
                index = que.pop()
                char_list.insert(index, " ")
            split_s = ""
            for c in char_list:
                split_s += c
            #print(split_s)
            answer += sum(map(int, split_s.split()))
    return answer

def main():
    S = input()

    print(solve(S))
#print(solve("125"))
#print(solve("9999999999"))
main()

Measured memory_bytes: 41072
#include "bits/stdc++.h"
using namespace std;

int main() {
	int a, b, c, d, ans;
	cin >> a >> b >> c >> d;
	while (1) {
		c -= b;
		if (c <= 0) {
			ans = 0;
			break;
		}
		a -= d;
		if (a <= 0) {
			ans = 1;
			break;
		}
	}
	if (ans) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 3632
import sys
from heapq import heapify, heappop, heappush

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]

    left = sum(A[:N])
    right = 0
    used = [False] * (3 * N)
    leftq, rightq = [], []
    heapify(leftq)
    heapify(rightq)
    for i, a in enumerate(A):
        if i < N: heappush(leftq, (a, i))
        else:heappush(rightq, (a, i))
    for _ in range(N):
        ca, ci = heappop(rightq)
        right += ca
        used[ci] = True

    Ans = left - right
    for i in range(N, 2 * N):
        left += A[i]
        heappush(leftq, (A[i], i))
        ma, mi = heappop(leftq)
        left -= ma

        if used[i] == True:
            right -= A[i]
            while rightq:
                pa, pi = heappop(rightq)
                if pi > i and not used[pi]:
                    right += pa
                    used[pi] = True
                    break

        Ans = max(Ans, left - right)
    print(Ans)
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 49116
#include <bits/stdc++.h>
using namespace std;
 
const int64_t INF=1e9+7;
 
int main(){
  int H,N;
  cin>>H>>N;
  vector<int64_t> A(N),B(N);
  for(int i=0;i<N;++i){
    cin>>A[i]>>B[i];
  }
 
  vector<vector<int64_t>> dp(N+1,vector<int64_t>(H+1));
  for(int j=0;j<=H;++j) dp[0][j]=INF;
 
  for(int i=0;i<N;++i){
    for(int j=0;j<=H;++j){
      if(j<=A[i]){
        if(dp[i][j]<B[i]) dp[i+1][j]=dp[i][j];
        else dp[i+1][j]=B[i];
      }
      else{
        if(dp[i+1][j-A[i]]+B[i]<dp[i][j]) dp[i+1][j]=dp[i+1][j-A[i]]+B[i];
        else dp[i+1][j]=dp[i][j];
      }
    }
  }
 
  cout<<dp[N][H]<<endl;
 
}

Measured memory_bytes: 78592
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  // input size
  int H, W;
  cin >> H >> W;

  // pre-processing
  bool mapFlag[H][W];
  char map[H][W];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> map[i][j];
      if (map[i][j] == '#') {
        mapFlag[i][j] = false;
      } else {
        mapFlag[i][j] = true;
      }
    }
  }

  // check
  bool inflag = false;
  for (int i = 0; i < H; i++) {
    inflag = false;
    for (int j = 0; j < W; j++) {
      if (map[i][j] == '.') {
        continue;
      }
      /* neighbor search */
      // cout << "n of (" << i << "," << j << ")" << endl;
      // D (+1, 0)
      int ni = std::min(i + 1, H - 1), nj = j;
      // cout << "ni nj (" << ni << "," << nj << "):" << map[ni][nj] << endl;
      if (map[i][j] == '#' && map[ni][nj] == '#' && ni != i) {
        mapFlag[i][j] = mapFlag[ni][nj] = true;
        inflag = true;
      }
      // U (-1, 0)
      ni = std::max(i - 1, 0), nj = j;
      // cout << "ni nj (" << ni << "," << nj << "):" << map[ni][nj] << endl;
      if (map[i][j] == '#' && map[ni][nj] == '#' && ni != i) {
        mapFlag[i][j] = mapFlag[ni][nj] = true;
        inflag = true;
      }
      // R (0, +1)
      ni = i, nj = std::min(j + 1, W - 1);
      // cout << "ni nj (" << ni << "," << nj << "):" << map[ni][nj] << endl;
      if (map[i][j] == '#' && map[ni][nj] == '#' && nj != j) {
        mapFlag[i][j] = mapFlag[ni][nj] = true;
        inflag = true;
      }
      // L (0, -1)
      ni = i, nj = std::max(j - 1, 0);
      // cout << "ni nj (" << ni << "," << nj << "):" << map[ni][nj] << endl;
      if (map[i][j] == '#' && map[ni][nj] == '#' && nj != j) {
        mapFlag[i][j] = mapFlag[ni][nj] = true;
        inflag = true;
      }

      // inflag -> impossilbe
      // cout << inflag << endl;
      if (!inflag) {
        break;
      }
    }
    // for (int i = 0; i < H; i++) {
    //   for (int j = 0; j < W; j++) {
    //     cout << (mapFlag[i][j] ? "T" : "F");
    //   }
    //   cout << endl;
    // }
    // cout << "----" << endl;
  }

  // all true or not
  bool flag = true;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (!mapFlag[i][j]) {
        flag = false;
        break;
      }
    }
    if (!flag) {
      break;
    }
  }
  // output
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

vector<int> dp(20, 0);

int main() {
    string s; cin >> s;
    int ans = 0;
    if (s[0] == 'A' || s[0] == 'T' || s[0] == 'G' || s[0] == 'C') {
        dp[0] = 1;
        ans = 1;
    }
    for (int i = 1; i < s.length(); i++) {
        if (s[i] == 'A' || s[i] == 'T' || s[i] == 'G' || s[i] == 'C') {
            dp[i] = dp[i - 1] + 1;
            chmax(ans, dp[i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256