akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush, heappop, heapify
N, K = map(int, input().split())
V = [int(i) for i in input().split()]
ans = 0

for i in range(min(K,N)+1):
  for l in range(i+1):
    H = []
    r = i-l
#    print(i,l,r)
    H.extend(V[:l])
    if r > 0:
      H.extend(V[-r:])
    heapify(H)
    for j in range(min(K-i,i)):
      if H[0] >= 0:
        break
      heappop(H)
    ans = max(ans,sum(H))
#  print(H)
print(ans)

Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int n,k,ans=-inf,sum=0,cur; cin>>n>>k;
    vector<int> v(n,0),s(n+1,0);
    rep(i,n){
        cin>>v[i];
        sum+=v[i];
        s[i+1]=sum;
    }
    rep(l,n+1)rep(r,n+1){
        if(l+r>min(n,k)) continue;
        int cnt=k-(l+r);
        cur=s[l]+s[n]-s[n-r];
        vector<int> vv;
        rep(i,l) vv.push_back(v[i]);
        rep(i,r) vv.push_back(v[n-1-i]);
        if(vv.size()>0) sort(al(vv));
        rep(i,min(cnt,(int)vv.size())){
            if(vv[i]>=0) break;
            cur-=vv[i];
        }
        ans=max(ans,cur);
    }
    cout<<ans<<endl;
}

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

// tourist set
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << '\n'; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
// tourist set end

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,b) FOR(i, 0, b)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<'\n'
#define p2(s, t) cout << (s) << " " << (t) << '\n'
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << '\n'
#define p_yes() p("YES")
#define p_no() p("NO")
#define SZ(x) ((int)(x).size())
#define SORT(A) sort(ALL(A))
#define RSORT(A) sort(ALL(A), greater<ll>())

void no(){p_no(); exit(0);}
void yes(){p_yes(); exit(0);}

const ll mod = 1e9 + 7;
const ll inf = 1e18;
const double PI = acos(-1);

ll divide(ll a){
  ll cnt=0;
  while(a%2==0){
    a/=2;
    cnt++;
  }
  return cnt;
}

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

    // input
    ll N; 
    cin >> N;

    ll sum = 0;
    rep(i, N){
      ll a; cin >> a;
      sum += divide(a);
    }
    p(sum);
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<map>
#include<cmath>
#define ll long long
#define inf 0x7fffffff;
#define maxn 1005
using namespace std;
int a,b,c,d; 
int read()
{
    int l=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
        w=-1;
        else
        ch=getchar();
    }
    while(ch<='9'&&ch>='0')
    {
        l*=10;
        l+=ch-'0';
        ch=getchar();
    }
    return l*w;
} 

int main()
{
	a=read(),b=read(),c=read(),d=read();
	int flag=1,ans;
	while(1)
	{
		if(flag==1)
		{
			c-=b;
			if(c<=0)
			{
				ans=1;
				break;
			}
		}
		else
		{
			a-=d;
			if(a<=0)
			{
				ans=2;
				break;
			}
		}
		flag=-flag;
	}
	if(ans==1)
	printf("Yes");
	else
	printf("No");
	return 0;
} 

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define Task        "test"
#define pb          emplace_back
#define fi          first
#define se          second
#define mp          make_pair
#define ll          long long
//#define int         int64_t

using namespace std;

typedef pair<ll, ll> pii;
const int N = 102;
const int M = 502;
const int mod = (int)1e9 + 7;

int n, len[N], x;
int f[N][M][M];

void add(int& x, int y) {if((x += y) >= mod) x -= mod;}
int mul(int x, int y) {return 1ll * x * y % mod;}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> x;
    for(int i = 1; i <= n; ++i) cin >> len[i];
    sort(len + 1, len + n + 1, greater<int>());
    /// f(i, j, len)
    f[1][1][len[1]] = 1;
    for(int i = 2; i <= n; ++i) {
        for(int j = 1, lim = min(i, x / len[i]); j <= lim; ++j) {
            for(int k = len[1]; k <= x; ++k) {
                /// add new segment
                add(f[i][j][k], mul(f[i - 1][j - 1][k - len[i]], j));
                for(int l = 0; l < len[i]; ++l) {
                    /// merges with one segment
                    if(l) add(f[i][j][k], mul(f[i - 1][j][k - l], 2 * j));
                    else if(k >= j * (len[i] - 1)) {
                       add(f[i][j][k], mul(f[i - 1][j][k], k - j * (len[i] - 1)));
                    }
                    /// merges two segments
                    add(f[i][j][k], mul(f[i - 1][j + 1][k - l], mul(len[i] - l - 1, j)));
                }
                //cout << i << ' ' << j << ' ' << k << ' ' << f[i][j][k] << '\n';
            }
        }
    }
    int res = 0;
    for(int i = 1; i <= n; ++i) add(res, f[n][i][x]);
    cout << res;
}


Measured memory_bytes: 98560
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int T;
	scanf("%d",&T);
	while(T--){
		int a,b;
		int x=0;
		int y=0;
		int tx=0;
		int ty=0;
		int p,q;
		while(scanf("%d%d",&p,&q),p||q){
			x+=p;y+=q;
			if(tx*tx+ty*ty<x*x+y*y||(tx*tx+ty*ty==x*x+y*y&&tx<x)){
				tx=x;ty=y;
			}
		}
		printf("%d %d\n",tx,ty);
	}
}

Measured memory_bytes: 1028
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+10;
int a[N];
int cn[N];

int main()
{
    int n;
    while(cin>>n)
    {
        int maxn=1;
        memset(cn,0,sizeof(cn));
        for(int i=0;i<n;i++){
            cin>>a[i];
            cn[a[i]]++,cn[a[i]-1]++,cn[a[i]+1]++;
            maxn=max(maxn,cn[a[i]]);
            maxn=max(maxn,cn[a[i]-1]);
            maxn=max(maxn,cn[a[i]+1]);
        }
        cout<<maxn<<endl;
    }
    return 0;
}


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

int main(void){
  vector<int> data(5);
  int ans = 0;
  int mind = 1000000;

  for(int i=0;i<5;i++){
    cin >> data[i];
  }
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      if(i == j) continue;
      ans += data[j];
      while(ans % 10 != 0){
        ans++;
      }
    }
    ans += data[i];
    mind = min(ans,mind);
    ans = 0;
  }
  cout << mind << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
    int n;
    cin >> n;
    vector<vector<ll>> happiness(n, vector<ll>(3));
    for(int i=0;i<n;++i){
        for(int j=0;j<3;++j) cin >> happiness[i][j];
    }

    vector<vector<ll>> dp(n+1, vector<ll>(3, 0)); // その日の終わりの幸福度合計
    for(int i=0;i<n;++i) {  // 今日の日数
        for(int j=0;j<3;++j) {  // 今日の activity
            for(int k=0;k<3;++k) {  // 明日の activity
                if(j == k) continue;
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + happiness[i][j]);
            }
        }
    }

    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}

Measured memory_bytes: 11136
#include <iostream>
using namespace std;
 
int main() {
  int base, h, m, s;
  cin >> base;
  h = base / 60 / 60;
  m = base / 60 % 60;
  s = base % 60;
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}

Measured memory_bytes: 1168
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

int main()
{
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            return 0;
        }

        vector<pair<int, int>> v;
        for (int i = 0; i < n; ++i) {
            int x, y;
            cin >> x >> y;
            v.emplace_back(x, y);
        }

        pair<int, int> pos(10, 10);
        int m;
        cin >> m;
        v.erase(remove(begin(v), end(v), pos), end(v));
        for (int i = 0; i < m; ++i) {
            char d;
            int x;
            cin >> d >> x;
            for (int j = x; j > 0; --j) {
                if (d == 'N' || d == 'S') {
                    int dy = d == 'N' ? 1 : -1;
                    pos.second += dy;
                }
                else {
                    int dx = d == 'E' ? 1 : -1;
                    pos.first += dx;
                }
                v.erase(remove(begin(v), end(v), pos), end(v));
            }
        }

        if (v.empty()) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 3088
#define _USE_MATH_DEFINES
#include<iostream>
#include<sstream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<math.h>
#include<iterator>

using namespace std;

int main(){
  int k,t;
  cin >> k >> t;
  vector<int> a(t);
  for (auto&& it : a) {
    cin >> it;
  }
  sort(a.begin(),a.end(),greater<int>());
  if(a[0]<=(k+1)/2){
    cout << "0" <<endl;
    return 0;
  }
  cout << 2*a[0]-k-1 <<endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val br = BufferedReader(InputStreamReader(System.`in`))
    val s = br.readLine()
    println(s.replace("2017", "2018"))
}

fun err(print: Any) {
    System.err.println(print)
}

Measured memory_bytes: 33864
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


class BIT:
    def __init__(self, n):
        self.num = n
        self.dat = [0] * (self.num + 1)
        self.depth = n.bit_length()

    def add(self, i, x):
        i += 1
        while i <= self.num:
            self.dat[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        s = 0
        while i > 0:
            s += self.dat[i]
            i -= i & -i
        return s


n, q = LI()
ans = [0] * q
C = LI()
Q = [[] for _ in range(n)]
for i in range(q):
    l, r = LI()
    Q[l - 1] += [(0, i)]
    Q[r - 1] += [(1, i)]


last = [-1] * (n + 1)
DD = {}
bit = BIT(n + 1)
now = 0
for i, c in enumerate(C):
    col = C[i]
    bit.add(i, 1)
    if last[col] != -1:
        bit.add(last[col], -1)
    last[col] = i
    for flg, qi in Q[i]:
        if flg:
            ans[qi] = bit.sum(i) - bit.sum(DD[qi] - 1)
        else:
            DD[qi] = i
        now += 1


#    print(q_now, "b")

print(*ans, sep="\n")

Measured memory_bytes: 273160
import java.util.*;
public class Main {

	/*
	 * 122B - 3rd Solution
	 * 
	 * We will loop through the right end point of the possible substring
	 * We will also store (lst) which is the last index where it is not a ACGT character
	 * If the right endpoint is not an AGCT character update lst
	 * We know that [lst+1, i] is a possible substring so update answer
	 * 
	 * Time Complexity O(N), Memory Complexity O(N)
	 * 
	 */
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int N = s.length();
		int ans = 0, lst = -1;
		for(int i = 0; i<N; i++) {
			if(s.charAt(i) != 'A' && s.charAt(i) != 'C' && s.charAt(i) != 'G' && s.charAt(i) != 'T') {
				lst = i;
			}
			ans = Math.max(ans, i-lst);
		}
		System.out.println(ans);
	}
}


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

int main(){
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin >> n; n--;
  cout << vec.at(n) << endl;
}

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

int main(){
  int N;
  cin >> N;
  
  int count = 0;
  if(1 <= N && N < 10){
    for(int i=1;i<=N;i++){
      count++;
    }
    cout << count << endl;
  }
  else if(10 <= N && N < 100){
      cout << 9 << endl;
  }
  else if(100 <= N && N < 1000){
    for(int i=100;i<=N;i++){
      count++;
    }
    cout << 9+count << endl;
  }
  else if(1000 <= N && N < 10000){
    cout << 909 << endl;
  }
  else if(10000 <= N && N < 100000){
    for(int i=10000;i<=N;i++){
      count++;
    }
    cout << 909+count << endl;
  }
  else if(N = 100000){
    cout << 90909 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n, b[512], f[512], r[512], v[512];
    int j[4][3][10] = { 0 };
    int a=0,i,m,k;

    scanf("%d",&n);
    for (i = 0; i < n; i++){
        scanf("%d%d%d%d",&b[i],&f[i],&r[i],&v[i]);
    }
    for (i = 0; i < n; i++){
        j[b[i]-1][f[i]-1][r[i]-1]+=v[i];
    }
    for (i = 0; i < 4; i++){
        if (a)printf("####################\n");
        for (m = 0; m < 3; m++){
            for (k = 0; k < 10; k++){
                printf(" %d",j[i][m][k]);
            }
            printf("\n");
            a = 1;
        }
    }
    return 0;
}

Measured memory_bytes: 1852
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;


int main(){
  int A,B,C,ans;
  cin>>A>>B>>C;

  for(int i=1;i<=A;i++){
    if(A%i==0 && B%i==0) ans=i;
  }
  //cout<<ans<<endl;
  if(C%ans!=0) cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[105];

int main(){
	int n,i,f=1;
	cin>>n;
	
	for(i=1;i<=n;i++)
	cin>>a[i];
	
	for(i=1;i<=n;i++)
	if(a[i]%2==0)
	if(a[i]%3!=0&&a[i]%5!=0){
		f=0;
		break;
	}
	
	if(f==1){
		cout<<"APPROVED";
	}else{
		cout<<"DENIED";
	}
	
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a = read::<i32>();
    let b = read::<i32>();
    let c = read::<i32>();
    println!("{}", std::cmp::min(b / a, c));
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//実行部
void Main()
{
  ll n; cin >> n;
  vll a;
  while (n)
  {
    a.pb(n % 10);
    n /= 10;
  }
  ll ans = 0, flag  = 0;
  rep(i, a.size() - 1)
  {
    if(a[i] != 9)
    {
      flag = 1;
    }
    ans += 9;
  }
  if(flag == 1)
  ans += (a[a.size() - 1] - 1);
  else
  ans += (a[a.size() - 1]);
  fin(ans);
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 1e9 + 7;

int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    int n, m;
    cin >> n >> m;
    int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
    cout << ans << endl;
    return 0;
}

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

int main() {
	int a,b;
	cin>>a>>b;
	if(a==b){
		cout<<2*a;
	}else if(a>b){
		cout<<2*a-1;
	}else{
		cout<<2*b-1;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{  
    int n ;
    cin >> n  ;
  
   int num , target = 0 ;
   num =  n ;
  
   while(num>0){
     target += num % 10 ;
     num /= 10 ;
  }
  
  if(n%target==0)
  cout << "Yes" << endl ;
  else
  cout << "No" << endl ;
  
   return 0;
}



Measured memory_bytes: 256
class Dice

  def initialize(dice)
    @top  = dice[0]
    @side   = [ dice[2], dice[1], dice[3], dice[4] ]
    @bottom = dice[5]
  end

  def roll(action)
    b = @bottom
    u = @top
    case action
    when "N"
      @top   = @side[2]
      @bottom  = @side[0]
      @side[2] = b
      @side[0] = u
    when "E"
      @top   = @side[3]
      @bottom  = @side[1]
      @side[3] = b
      @side[1] = u
    when "S"
      @top   = @side[0]
      @bottom  = @side[2]
      @side[0] = b
      @side[2] = u
    when "W"
      @top   = @side[1]
      @bottom  = @side[3]
      @side[1] = b
      @side[3] = u
    end
  end

  def same_dice?(sub)
    i = 0
    while true
      if south == sub.south
        4.times do
          if all_num == sub.all_num
            return true
          end
          roll("E")
        end
      end
      if i > 6
        return false
      elsif i == 3
        roll("E")
        roll("N")
      else
        roll("N")
      end
      i += 1
    end
  end

  def top
    @top
  end

  def bottom
    @bottom
  end

  def north
    @side[0]
  end

  def east
    @side[1]
  end

  def south
    @side[2]
  end

  def west
    @side[3]
  end

  def all_num
    [@top, @bottom, @side[2], @side[1], @side[3], @side[4]]
  end
end

gets
dice = Dice.new(gets.split.map(&:to_i))

ARGF.each do |line|
  dice_2 = Dice.new(line.split.map(&:to_i))
  if dice_2.same_dice?(dice)
    puts "No"
    exit
  end
end
puts "Yes"

Measured memory_bytes: 8928
#include <iostream>
#include <set>
#include <queue>
#include <vector>
using namespace std;

const int MAX_N = (1 << 20);

// 入力
int H, W, K;
int SX, SY, GX, GY;
string S[MAX_N];

// 累積和
vector<int> AL[MAX_N];
vector<int> AR[MAX_N];
vector<int> BL[MAX_N];
vector<int> BR[MAX_N];

// 最短路
set<int> S1[MAX_N], S2[MAX_N];
vector<int> dist[MAX_N];
queue<pair<int, int>> Q;

void solve(int px, int py) {
	// 横方向
	int cl = AL[px][py], cr = AR[px][py];
	auto itr1 = S1[px].lower_bound(cl);
	vector<pair<int, int>> Mass1;
	while (itr1 != S1[px].end()) {
		int pv = (*itr1); if (pv > cr) break;
		Mass1.push_back(make_pair(px, pv));
		itr1++;
	}
	for (pair<int, int> i : Mass1) {
		dist[i.first][i.second] = dist[px][py] + 1;
		Q.push(make_pair(i.first, i.second));
		S1[i.first].erase(i.second);
		S2[i.second].erase(i.first);
	}

	// 縦方向
	int dl = BL[px][py], dr = BR[px][py];
	auto itr2 = S2[py].lower_bound(dl);
	vector<pair<int, int>> Mass2;
	while (itr2 != S2[py].end()) {
		int pv = (*itr2); if (pv > dr) break;
		Mass2.push_back(make_pair(pv, py));
		itr2++;
	}
	for (pair<int, int> i : Mass2) {
		dist[i.first][i.second] = dist[px][py] + 1;
		Q.push(make_pair(i.first, i.second));
		S1[i.first].erase(i.second);
		S2[i.second].erase(i.first);
	}
}

int main() {
	// 入力
	cin >> H >> W >> K;
	cin >> SX >> SY >> GX >> GY; SX--; SY--; GX--; GY--;
	for (int i = 0; i < H; i++) cin >> S[i];

	// 準備
	for (int i = 0; i < H; i++) dist[i].resize(W, 1 << 30);
	for (int i = 0; i < H; i++) AL[i].resize(W, 0);
	for (int i = 0; i < H; i++) AR[i].resize(W, W - 1);
	for (int i = 0; i < H; i++) BL[i].resize(W, 0);
	for (int i = 0; i < H; i++) BR[i].resize(W, H - 1);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) { if (S[i][j] != '@') S1[i].insert(j); }
		for (int j = 0; j < W; j++) { if (S[i][j] != '@') S2[j].insert(i); }
	}

	// 累積和
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (j != 0) AL[i][j] = AL[i][j - 1];
			if (i != 0) BL[i][j] = BL[i - 1][j];
			if (S[i][j] == '@') AL[i][j] = j + 1;
			if (S[i][j] == '@') BL[i][j] = i + 1;
			AL[i][j] = max(AL[i][j], j - K);
			BL[i][j] = max(BL[i][j], i - K);
		}
	}
	for (int i = H - 1; i >= 0; i--) {
		for (int j = W - 1; j >= 0; j--) {
			if (j != W - 1) AR[i][j] = AR[i][j + 1];
			if (i != H - 1) BR[i][j] = BR[i + 1][j];
			if (S[i][j] == '@') AR[i][j] = j - 1;
			if (S[i][j] == '@') BR[i][j] = i - 1;
			AR[i][j] = min(AR[i][j], j + K);
			BR[i][j] = min(BR[i][j], i + K);
		}
	}

	// 最短路
	Q.push(make_pair(SX, SY)); dist[SX][SY] = 0;
	S1[SX].erase(SY); S2[SY].erase(SX);
	while (!Q.empty()) {
		int cx = Q.front().first, cy = Q.front().second; Q.pop();
		solve(cx, cy);
	}

	// 出力
	if (dist[GX][GY] == (1 << 30)) cout << "-1" << endl;
	else cout << dist[GX][GY] << endl;
	return 0;
}

Measured memory_bytes: 370972
#include<iostream>
#include<stdio.h>
using namespace std;
#include<math.h>
int main()
{
	static int c,n,a,b,s,f,y[1002];
	cin>>a>>b>>n;
	for(int i=0;i<n;i++)
	{
		cin>>s>>f;
		for(int j=s;j<f;j++)
			y[j]=1;
	}
	for(int i=a;i<=b-1;i++)
	{
		if(y[i]==1)
			break;
		else
			c++;	
	}
	if(b-a==c)
		cout<<"0"<<endl;
	else
		cout<<"1"<<endl;
	return 0;
}


Measured memory_bytes: 3108
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i;
  int ln;
  string s;
  cin>>s;
  ln=s.length();
  for(i=0;i<ln;i++)
    s[i]=s[i]-3<'A'?s[i]+23:s[i]-3;
  cout<<s<<endl;
  return 0;
}

Measured memory_bytes: 0
#include"bits/stdc++.h"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	int a, b, k,ans;
	cin >> a >> b >> k;
	int num = 1;
	for (int i = min(a, b); i > 0; i--) {
		if (a%i == 0 && b%i == 0) {
			if (num == k) { ans = i; break; }
			else { num++; }
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<complex>
typedef long long int llint;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int n;
	cin >> n;
	vector < pair<llint, llint> > a(n);
	vector < pair<llint, int> > b(n);
	rep(i, n) {
		cin >> a[i].first >> a[i].second;
		b[i].first = a[i].first + a[i].second;
		b[i].second = i;
	}
	sort(b.begin(), b.end());
	llint ans = 0;
	rep(i, n) {
		if (i % 2 == 0) {
			ans += a[b[n - 1 - i].second].first;
		}
		else {
			ans -= a[b[n - 1 - i].second].second;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  while( 1 ) {
    int all;
    cin >> all;
    if( !all ) { break; }
    for( int i = 0; i < 9; i++ ) {
      int a;
      cin >> a;
      all -= a;
    }

    cout << all << endl;
  }

  return EXIT_SUCCESS;
}

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

using namespace std;

#define MAXN 20

int dp[MAXN];

bool check(char c){
	if(c == 'A' || c == 'C' || c == 'T' || c == 'G')return true;
	return false;
}


int main(){
	#ifdef EVAL 
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	string s;
	cin >> s;
	int res = 0;
	if( check(s[0]))dp[0] = 1;
	for(int i = 0,N = s.size(); i < N; i++){
		if(check(s[i])){
			dp[i] = dp[i - 1] + 1;
			res = max(res,dp[i]);
		}
	}
	cout << res;

}

Measured memory_bytes: 256
x,n = map(int,input().split())
l = list(map(int,input().split()))
i=0
while True:
    k1 = x-i
    if not(k1 in l):
        print(k1)
        break
    k2 = x+i
    if not(k2 in l):
        print(k2)
        break
    i+=1

Measured memory_bytes: 61836
#include<bits/stdc++.h>
using namespace std;
const int N=4005,mod=998244353;
int n,k,pw[N],C[N][N];
int c(int n,int m){if(m<0||n<0)return 0;return C[n][m];}
int calc(int x,int n,int k)
{
	int ans=0,tot=max(0,x/2-max(0,x-1-k));
	for(int i=0;i<=tot;i++)ans=(1ll*pw[i]*C[tot][i]%mod*c(n+k-2*tot-1,k-tot*2+i-1)+ans)%mod;
	return ans;
}
int main()
{
	for(int i=pw[0]=1;i<N;i++)pw[i]=(pw[i-1]*2)%mod;
	for(int i=0;i<N;i++)C[i][0]=1;
	for(int i=1;i<N;i++)for(int j=1;j<=i;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	scanf("%d%d",&k,&n);
	for(int i=2;i<=2*k;i++)if(i&1)printf("%d\n",calc(i,n,k));else printf("%d\n",(calc(i-1,n,k-1)+calc(i-1,n-1,k-1))%mod);
	return 0;
}

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

int main() {
    string S; cin >> S;
    int A = S.at(0) - '0', B = S.at(1) - '0', C = S.at(2) - '0', D = S.at(3) - '0';
    for (int i = 0; i < (1 << 3); i++) {
        bool sign[3];
        for (int j = 0; j < 3; j++) {
            if (i & (1 << j)) sign[j] = true;
            else sign[j] = false;
        }
        int num = A;
        if (sign[0]) num += B;
        else num -= B;
        if (sign[1]) num += C;
        else num -= C;
        if (sign[2]) num += D;
        else num -= D;
        if (num == 7) {
            cout << A << (sign[0] ? '+' : '-') << B << (sign[1] ? '+' : '-') << C << (sign[2] ? '+' : '-') << D << "=7" << endl;
            return 0;
        }
    }
}

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

int main(){
	int n;
	cin>>n;
	int d;
	cin>>d;
	int count = 0;
	for(int i=0;i<n;i++){
		 long long  a,b;
		cin>>a>>b;
		long long  check = a*a + b*b;
		double ye = sqrt(check);
		if(ye<=d) count++;
	}
	cout<<count;
	
}

Measured memory_bytes: 3676
/**
 *    author:  tourist
 *    created: 26.11.2019 11:07:03       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, tt;
  cin >> n >> tt;
  n *= 2;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  multiset<pair<int, int>> pos;
  multiset<pair<int, int>> neg;
  long long sum_pos = 0;
  long long sum_neg = 0;
  for (int i = 1; i < n - 1; i++) {
    if (a[i] > b[i]) {
      pos.emplace(a[i] - b[i], a[i]);
      sum_pos += a[i];
    } else {
      neg.emplace(b[i] - a[i], b[i]);
      sum_neg += b[i];
    }
  }
  while (tt--) {
    int i;
    cin >> i;
    --i;
    if (i > 0 && i < n - 1) {
      if (a[i] > b[i]) {
        pos.erase(pos.find({a[i] - b[i], a[i]}));
        sum_pos -= a[i];
      } else {
        neg.erase(neg.find({b[i] - a[i], b[i]}));
        sum_neg -= b[i];
      }
      cin >> a[i] >> b[i];
      if (a[i] > b[i]) {
        pos.emplace(a[i] - b[i], a[i]);
        sum_pos += a[i];
      } else {
        neg.emplace(b[i] - a[i], b[i]);
        sum_neg += b[i];
      }
    } else {
      cin >> a[i] >> b[i];
    }
    long long ans = a[0] + a[n - 1] + sum_pos + sum_neg;
    if (pos.size() % 2 == 1) {
      ans -= min(pos.begin()->first, neg.begin()->first);
    }
    cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 12800
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);   

int main(){
    std::ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    a+=12345;
    b+=12345;
    c+=12345;
    a^=b;
    a^=c;
    a-=12345;
    cout<<a<<endl;
    return 0;
    return 0;  
    
}



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

int main() {
  int n;
  cin >> n;
  bool flag = false;

  for(int i = 0; i < n; i++){
      string s;
      cin >> s;
      if (s == "Y"){
          flag = true;
          break;
      }
  }
  if (flag) cout << "Four" << endl;
  else cout << "Three" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
S = []

a = [0] * 6
for A in range(1, N):
    realA = A
    for i in [5,4,3,2,1,0]:
       a[i] = A // (10**i)
       A = A % (10**i)
       
    b = [0] * 6
    B = N - realA
    for i in [5,4,3,2,1,0]:
        b[i] = B // (10**i)
        B = B % (10**i)
        
    def sum(x):
        sum = 0
        for i in range(6):
            sum += x[i]
        return sum
    S.append(sum(a)+sum(b))
print(min(S))

Measured memory_bytes: 3864
from sys import stdin, setrecursionlimit
from collections import deque

setrecursionlimit(10 ** 9)

H, W = map(int, stdin.readline().split())
field = [list(stdin.readline().rstrip()) for _ in range(H)]

inf = 10 ** 9

flip_cnt = [[inf] * W for _ in range(H)]
direction = [[0, 1], [1, 0]]

q = deque([])


def bfs(h, w):
    q.append([h, w])

    while q:

        h, w = q.popleft()

        for dh, dw in direction:
            nh = h + dh
            nw = w + dw

            if nh >= H or nw >= W:
                continue

            if field[nh][nw] == field[h][w]:
                if flip_cnt[nh][nw] <= flip_cnt[h][w]:
                    continue
                else:
                    flip_cnt[nh][nw] = flip_cnt[h][w]
                    q.append([nh, nw])
            else:
                if flip_cnt[nh][nw] <= flip_cnt[h][w] + 1:
                    continue
                else:
                    flip_cnt[nh][nw] = flip_cnt[h][w] + 1
                    q.append([nh, nw])


flip_cnt[0][0] = 0
bfs(0, 0)

if field[0][0] == field[H - 1][W - 1] == "#":
    flip_cnt[H - 1][W - 1] += 1

print((flip_cnt[H - 1][W - 1] + 1) // 2)

# for f in flip_cnt:
#     print(f)


Measured memory_bytes: 3436
N = int(input())
A = list(map(int,input().split()))
flag = True
ans = 0
for i in range(N):
    flag = False
    for j in range(N-1,i,-1):
        if A[j] < A[j-1]:
            A[j],A[j-1] = A[j-1],A[j]
            flag = True
            ans += 1
    if not flag:
        break
print(*A)
print(ans)



Measured memory_bytes: 5612
S = list(input())

def judge1(S):
  for j in range(len(S)):
    judge = 1
    if((S[j]=='A')or(S[j]=='G')or(S[j]=='T')or(S[j]=='C')):
      continue
    else:
      judge = 0
      break
  return judge 

ans = 0
judge = 0
for i in range(len(S)):
  j = 0
  k = len(S) - i
  
  while(1):
   if(j+k-1 > len(S)-1):
    break
   tmp_S = S[j:j+k]
   judge = judge1(tmp_S)
   if(judge == 1):
    ans = len(tmp_S)
    break
   j += 1
  if(judge == 1):
    break
      
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmax(a,b) a=max(a,b);
#define chmin(a,b) a=min(a,b);
class Segtree{
	
	private:
	int V;
	typedef struct st{
		ll a,len;
	}st;
	st st0=(st){(ll)0,1};
	typedef struct op{
		ll a;
	}op;
	op op0=(op){0};
	st f(st p,st q){
		return (st){p.a+q.a,p.len+q.len};
	}
	void g(st &p,op q){
		p.a+=q.a*p.len;
	}
	void h(op &p,op q){
		p.a+=q.a;
	}
	
	st *dat;
	op *laz;
	
	st propagate(ll k){
		if(k<V){
			h(laz[k*2],laz[k]);
			h(laz[k*2+1],laz[k]);
		}
		g(dat[k],laz[k]);
		laz[k]=op0;
		return dat[k];
	}
	void upd(ll l,ll r,op p){
		l+=V,r+=V+1;
		for(ll d=20;d>=0;d--){
			propagate(l>>d);
			propagate(r>>d);
		}
		for(ll a=l,b=r;a<b;a>>=1,b>>=1){
			if(a&1){h(laz[a],p);a++;}
			if(b&1){b--;h(laz[b],p);}
		}
		for(ll a=l,b=r;a+b;a>>=1,b>>=1){
			dat[a/2]=f(propagate(a/2*2),propagate(a/2*2+1));
			dat[b/2]=f(propagate(b/2*2),propagate(b/2*2+1));
		}
	}
	st qry(ll l,ll r){
		l+=V,r+=V+1;
		for(ll d=20;d>=0;d--){
			propagate(l>>d);
			propagate(r>>d);
		}
		st L=st0,R=st0;
		for(ll a=l,b=r;a<b;a>>=1,b>>=1){
			if(a&1){L=f(L,propagate(a));a++;}
			if(b&1){b--;R=f(propagate(b),R);}
		}
		st res=f(L,R);
		return res;
	}
	
	public:
	void init(int ns){
		V=1;
		while(V<=ns)V*=2;
		dat=new st[2*V];
		laz=new op[2*V];
		for(int i=0;i<2*V;i++){
			dat[i]=st0;
			laz[i]=op0;
		}
		
		ll *len=new ll[2*V];
		for(int i=2*V-1;i>=0;i--){
			if(V<=i)len[i]=1;
			else len[i]=len[i*2]*2;
			dat[i]=(st){0,len[i]};
			laz[i]=op0;
		}
	}
	void update(ll l,ll r,ll a){
		upd(l,r,(op){a});
	}
	ll query(ll l,ll r){
		st res=qry(l,r);
		return res.a;
	}
};
Segtree seg;

int main(){
	int n,q;
	cin>>n>>q;
	seg.init(n+1);
	rep(i,n)seg.update(i,i,0);
	while(q--){
		ll p,s,t,x;
		cin>>p;
		if(p==0){
			cin>>s>>t>>x;
			seg.update(s,t,x);
		}
		if(p==1){
			cin>>s>>t;
			cout<<seg.query(s,t)<<"\n";
		}
	}
}



Measured memory_bytes: 11308
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define debug(x) cerr << #x " = " << (x) << endl;
#define P(x) cerr << #x << endl;    
typedef long long ll;
#define int long long
//#define int unsigned long long
const int mod = 1000000007;
 
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(9);
    
    
    string s, t;
    cin >> s >> t;
    int lens = s.length();
    int lent = t.length();
    vector<int> cnt1(30, 0);
    vector<int> cnt2(30, 0);
    vector<vector<int>> index(30);
    
    for(int i = 0; i < lens; ++ i)
    {
        ++ cnt1[s[i] - 'a'];
        index[s[i] - 'a'].push_back(i);
    }
    
    for(int i = 0; i < lent; ++ i)
    {
        ++ cnt2[t[i] - 'a'];
    }
    bool can = true;
    for(int i = 0; i < 26; ++ i)
    {
        if(cnt2[i] > 0 && cnt1[i] == 0)
        {
            can = false;
            break;
        }
    }
    
    if(can)
    {
        int ans = 0;
        int last = -1;
        vector<int> at(30, 0);
        vector<int> vec;
        
        for(int i = 0; i < lent; ++ i)
        {
            int cur = t[i] - 'a';
//            debug(cur);
//            debug(at[cur]);
//            debug(last);
            
            while(index[cur][at[cur]] <= last && at[cur] < index[cur].size())
            {
                ++ at[cur];
            }
            
            if(at[cur] >= index[cur].size())
            {
                for(int j = 0; j < 26; ++ j)
                {
                    at[j] = 0;
                }
                i -= 1;
                ans += lens;
                last = -1;
//                P(here inside); 
            }
            else if(index[cur][at[cur]] <= last)
            {
                
                for(int j = 0; j < 26; ++ j)
                {
                    at[j] = 0;
                }
                i -= 1;
                ans += lens;
                last = -1;
//                P(here inside); 
            }
            else
            {
//                debug(index[cur][at[cur]]);
                
                last = index[cur][at[cur]];
                
                vec.push_back(index[cur][at[cur]]);
//                debug(vec[vec.size() - 1]);
                ++at[cur];
            }
//            debug(ans);
        }
        ans += vec[vec.size() - 1] + 1;
        cout << ans << endl;
        
    }
    else
    {
        cout << "-1" << endl;
    }
    
    
    return 0;
}
 


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

using namespace std;


int main()
{

    string s;

    cin >> s;

    int sz = s.size();
    int c0 = 0, c1 = 0;

    for(int i = 0; i < sz; i++)
    {
        if(s[i] == '0')
          c0++;
        else
           c1++;
    }

    cout << min(c0,c1) * 2 << endl;


    return 0;
}


Measured memory_bytes: 512
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()

	ans := 0
	for i := 1; i < n+1; i++ {
		if i%2==0 {
			continue
		}
		c := 0
		for j := 1; j < i+1; j++ {
			if i%j == 0 {
				c++
			}
		}
		if c == 8 {
			ans++
		}
	}

	fmt.Fprintln(wr,ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int N=2e5+10;
const int mod=0;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
int n,a[N],b[N],vis[N];
ll sa=0,sb=0,ret=0,sum=0;
pii p[N];
int main() {
    n=gi();
    for(int i=1;i<=n;i++) {
        a[i]=gi(),b[i]=gi();
        sum+=a[i]+b[i],sa+=a[i],sb+=b[i];
        p[2*i-1]=mp(a[i],i),p[2*i]=mp(b[i],i);
    }
    ret=max(sa,sb);
    sort(p+1,p+2*n+1,greater<pii>());
    int fl=0;
    ll tmp=0;
    for(int i=1;i<=n;i++) {
        if(vis[p[i].se]) fl=1;
        tmp+=p[i].fi,vis[p[i].se]=1;
    }
    if(fl) chkmax(ret,tmp);
    else {
        for(int i=n+1;i<=2*n;i++) {
            if(p[i].se==p[n].se) chkmax(ret,tmp+p[i].fi-p[n-1].fi);
            else chkmax(ret,tmp+p[i].fi-p[n].fi);
        }
    }
    printf("%lld\n",sum-ret);
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

signed main() {
	int x;
	cin >> x;
	
	cout << (x / 500) * 1000 + ((x % 500) / 5) * 5 << endl;
	
	return 0;
}

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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A=in();
    int B=in();
    int ans;
    if(A<=5){
        ans=0;
    }else if(A<=12){
        ans=B/2;
    }else{
        ans=B;
    }    
    print(ans);
    return 0;
}


Measured memory_bytes: 3584
/*
  AOJ #2801
  title:Suntan
  @kankichi573
  2017/10/29 WA 2/55
  2017/10/29 WA 4/55
 */
#include <stdio.h>
#define max(x,y) ((x>y)?(x):(y))
#define min(x,y) ((x<y)?(x):(y))
typedef long long LL ;

int N;
LL T,s[100001],t[100001];

struct period_st
{
  LL time_;
  char flag;
}
period_table[400001];

void dump()
{
  int i;
  
  for(i=0;i<N;i++)
    printf("%lld %lld\n",s[i],t[i]);
}

void dump2()
{
  int i;
  printf("-------\n");
  for(i=0;i<N*4;i++)
    printf("%lld|%d\n",period_table[i].time_,period_table[i].flag);
  printf("\n");
}

int comp( const void * a , const void * b ) {

  if((((struct period_st *)a)->time_) < (((struct period_st *)b)->time_ ))
    return -1;
     else 
  if((((struct period_st *)a)->time_) < (((struct period_st *)b)->time_ ))
    return 0;
  else
  return 1;
}


int main()
{
  int i,j,fg,bg,en;
  LL ret,tt,ss;
  LL start,start_end,val,last,tm,oldtm;
  
  scanf("%lld",&T);
  scanf("%d",&N);

  
  for(i=j=0;i<N;i++)
    {
      scanf("%lld %lld",&ss,&tt);
      s[i]=ss,t[i]=tt;
      
      period_table[j].time_ = ss;
      period_table[j].flag = 1;
      j++;
      period_table[j].time_ = tt;
      period_table[j].flag = 2;
      j++;
      period_table[j].time_ = ss - T;
      period_table[j].flag = 3;
      j++;
      period_table[j].time_ = tt - T;
      period_table[j].flag = 4;
      j++;
    }

  if(N==1)
    {
      ret=min(T,t[0]-s[0]);
      printf("%lld\n",ret);
      return(0);
    }

  start=s[0];
  last =t[N-1];
  start_end = start+T;

  //printf("start=%d last=%d start_end=%d\n",start,last,start_end);
  

  for(j=val=0;j<N;j++)
  {
    if(t[j]<=start_end)
      {
	val += (t[j]-s[j]);
      }
    else if(t[j]>start_end && s[j]<start_end)
      {
	val += (start_end-s[j]);
	en=1;
	break;
      }
    else if(t[j]>=start_end)
      {
	en=0;
	break;
      }
  }
  //printf("#0 %lld~%lld val=%lld \n",start,start_end,val);
  
  qsort(period_table,N*4,sizeof(struct period_st),comp);
  //dump();
  //dump2();  
  oldtm = start;

  bg=1;
  ret=val;
  for(i=0;i<N*4;i++)
    {
      tm=period_table[i].time_;
      fg=period_table[i].flag;
  
      if(tm <= start)
	continue;
      if(tm+T > last) 
	break;

      val += (tm-oldtm)*(en-bg);

      //printf("*next=%lld diff=%lld:",tm,tm-oldtm);
      //printf("#%d %lld~%lld %lld enbg=%d %d\n",i,tm,tm+T,val,en,bg);
      
      ret=max(ret,val);

      if(fg==1)
	bg = 1;
      else if(fg==2)
	bg = 0;
      else if(fg==3)
	en = 1;
      else if(fg==4)
	en = 0;

      oldtm=tm;
    }
  printf("%lld\n",ret);
  
  return(0);
}

Measured memory_bytes: 14008
local n,k=io.read("n","n")
local a={}
for i=1,n do
    a[i]=io.read("n")
end

local dp={}
for i=1,n+1 do
    dp[i]={}
    dp[i][1]=1
    for j=2,k+1 do
        dp[i][j]=0
    end
end

local mod=1000000007
for i=1,n do
    for j=2,k+1 do
        if j-1-a[i]>0 then
            dp[i+1][j]=(dp[i+1][j-1]+dp[i][j]-dp[i][j-1-a[i]])%mod
        else
            dp[i+1][j]=(dp[i+1][j-1]+dp[i][j])%mod
        end
    end
end
print(dp[n+1][k+1])

Measured memory_bytes: 106484
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(void)
{
    ll a, b;
    scanf("%lld%lld", &a, &b);
    ll now = a;
    int ans = 1;
    while (true){
        if (now<<1<=b){
            ans++;
            now <<= 1;
        }
        else{
            break;
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int main(){
    ll n,k; cin >> n >> k;
    map<ll,ll> mp;
    rep(i,n){
        int a,b; cin >> a >> b;
        mp[a]+=b;
    }
    for(auto itr=mp.begin();itr!=mp.end();++itr){
        if(itr->second<k){
            k-=itr->second;
        }
        else{
            cout << itr->first << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 4224