akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  vector<vector<bool>> ok(3,vector<bool>(3,false));
  vector<vector<int>> c(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>c[i][j];
    }
  }
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    int s;
    cin>>s;
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
      if(s==c[j][k]){
      ok[j][k]=true;
      }
      }
    }
  }
  for(int i=0;i<3;i++){
    int count=0;
    for(int j=0;j<3;j++){
      if(ok[i][j]){
        count++;
      }
      else{
        count=0;
      }
    }
    if(count==3){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  for(int i=0;i<3;i++){
    int count=0;
    for(int j=0;j<3;j++){
      if(ok[j][i]){
        count++;
      }
      else{
        count=0;
      }
    }
    if(count==3){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  int count=0;
  for(int i=0;i<3;i++){
      if(ok[i][i]){
        count++;
      }
      else{
        count=0;
      }
    if(count==3){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  count=0;
  for(int i=2;i>=0;i--){  
    if(ok[i][2-i]){
        count++;
      }
      else{
        count=0;
      }
    if(count==3){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

  

Measured memory_bytes: 3632
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
int main() {
  int a,b,ans;
  cin>>a>>b;
  if(a>=b+2) ans=a+a-1;
  else if(b>=a+2) ans=b+b-1;
  else ans=a+b;
  cout<<ans;
  return 0;
}

Measured memory_bytes: 256
n,h = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)
s = []
len = n
ans = 0
sum = 0
(n).times do|i|
    sum+= a[i] if a[i] > 0
end
poet = 0
h.times do |d|
  sum -= a[d] if(a[d] > 0)
  poet += a[d]
end
str = 0
en = (h-1) 
max = poet
min = poet
(n-h).times do |u|
  poet += a[h+u]
  poet -= a[u]
  sum += a[u] if(a[u] > 0)
  sum -= a[h+u] if(a[h+u] > 0)
  ans = sum
  ans += poet if poet > 0
  if(ans > max)
  max = ans
  end 
end

if (max < 0)
  puts 0
  exit
end
puts  max
=begin
5 3
-10 10 -10 10 -10
=end

Measured memory_bytes: 9876
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
int n,l[105];
map<int,int> num;
int main(){
    scanf("%d",&n);
    rep(i,1,n) {
        scanf("%d",&l[i]);
    }
    sort(l+1,l+n+1);
    int ans=0;
    rep(i,1,n) rep(j,i+1,n) {
        if(l[i]==l[j]) continue;
        int kel=l[i]+l[j];
        for(int k=j+1;l[k]<kel&&k<=n;++k) {
            if(l[j]==l[k]) continue;
            ++ans;
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> S(M), C(M);
  for (int i = 0; i < M; i++) {
    int s, c;
    cin >> s >> c;
    S.at(i) = s;
    C.at(i) = c;
  }
  vector<vector<int>> digit(N);
  for (int i = 0; i < M; i++) {
    digit.at(S.at(i) - 1).push_back(C.at(i));
  }
  bool exceed = false;
  for (int i = 0; i < N; i++) {
    if (digit.at(i).size() > 1) {
      set<int> SET;
      for (int j = 0; j < digit.at(i).size(); j++) {
        SET.insert(digit.at(i).at(j));
      }
      if (SET.size() > 1) {
        exceed = true;
      }
    }
  }
  // 同じ桁に異なる数字が入る場合を除去
  if (exceed) {
    cout << -1 << endl;
    return 0;
  }
  // N > 2のときに1桁目に0がある場合を除去
  if (!digit.at(0).empty()) {
    if (digit.at(0).at(0) == 0 && N != 1) {
      cout << -1 << endl;
      return 0;
    }
  }
  vector<int> nums = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (!digit.at(i).empty())
      ans += nums.at(digit.at(i).at(0)) * pow(10, N - i - 1);
  }
  if (to_string(ans).size() == N)
    cout << ans << endl;
  else
    cout << ans + pow(10, N - 1) << endl;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n, m;
int x[100005];
int c[100005];
int p[100005];
void solve() {
    cin >> n >> m;

    map<int, int> mp;
    rep(i, n) {
        cin >> x[i];
        ++mp[x[i]];
    }

    for (auto& s : mp) {
        c[s.first % m] += s.second;
        p[s.first % m] += s.second / 2;
    }

    int ans = 0;
    rep(i, m) {
        auto j = (m - i) % m;

        if (i > j) break;
        if (i == j) {
            ans += c[i] / 2;
        }
        else {
            auto cc = min(c[i], c[j]);
            ans += cc;
            ans += min(p[i] * 2, c[i] - cc) / 2;
            ans += min(p[j] * 2, c[j] - cc) / 2;
        }
    }

    cout << ans << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

bool check(V< V<bool> > bin) {
    bool ok = false;
    for (int i = 0; i < 3; i++) {
        ok |= bin[i][0] && bin[i][1] && bin[i][2];
    }
    for (int i = 0; i < 3; i++) {
        ok |= bin[0][i] && bin[1][i] && bin[2][i];
    }
    ok |= bin[0][0] && bin[1][1] && bin[2][2];
    ok |= bin[0][2] && bin[1][1] && bin[2][0];
    return ok;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    V< V<int> > a(3, V<int>(3));
    for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) cin >> a[i][j];
    int n; cin >> n;
    V< V<bool> > used(3, V<bool>(3, false));
    for (int i = 0; i < n; i++) {
        int b; cin >> b;
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (a[j][k] == b) used[j][k] = true;
            }
        }
    }

    if (check(used)) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=2e5 +10, M=(ll)1e9+1 ;
const int mod =(ll)1e9+7 ,sz=5, MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";

void work(){
  ll n,m;
  cin >> n >> m;
  ll a[n][m],dp[n][m];
  for(ll i=0;i<n;i++){
    for(ll j=0;j<m;j++){
        char c;
        cin >> c;
        a[i][j]=(c=='#');
    }
  }
 
  for(ll i=0;i<n;i++){
    for(ll j=0;j<m;j++){
        dp[i][j]=INF;
        if(i+j==0)
            dp[i][j]=a[0][0];
        else 
            if(i>0)
                dp[i][j]=min(dp[i][j],dp[i-1][j]+(a[i-1][j]==0 && a[i][j]==1));
            if(j>0)
                dp[i][j]=min(dp[i][j],dp[i][j-1]+(a[i][j-1]==0 && a[i][j]==1));
        // cout << dp[i][j] << " ";
    }
    // cout << "\n";
  }
  cout << dp[n-1][m-1];

} 
int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0);
    ll t;
    // cin >> t;
    t=1;
    while(t--){
            work();
    }
   return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int N;
    int P[214514];
    cin >> N;
    REP(i,N){
        cin >> P[i];
    }
    int mn=INF;
    int Ans=0;
    REP(i,N){
        if(P[i]<mn){
            mn=P[i];
            Ans++;
        }
    }
    cout << Ans << endl;
    return 0;
}



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

int main(){
  cout<<fixed<<setprecision(12);


  while(1){
    int n;
    double s[1000];
    double sum=0;

    cin>>n;
    
    if(n==0){
      break;
    }
    
    for(int i=0;i<n;i++){
      cin>>s[i];
    }
  
    for(int i=0;i<n;i++){
      sum+=s[i];
    }
  
    double avg=sum/n;

    double ans=0;
  
    for(int i=0;i<n;i++){
      ans+=pow(s[i]-avg,2);
    }

    ans=sqrt( ans/n );
  
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3296
// Written By NewbieChd
#include <cstdio>
#include <cctype>
#define int long long
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    register int f = 0;
    char c;
    while (!isdigit(c = getChar())) {}
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return f;
}

const int maxN = 100003;
int a[maxN], x[maxN];

signed main() {
    int n = read(), i, sum = 0, odd = 0;
    for (i = 1; i <= n; ++i) {
        sum += a[i] = read();
        if (i & 1)
            odd += a[i];
    }
    x[1] = (odd << 1) - sum;
    for (i = 2; i <= n; ++i)
        x[i] = (a[i - 1] << 1) - x[i - 1];
    for (i = 1; i <= n; ++i)
        printf("%lld ", x[i]);
    return 0;
}


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

#define mp make_pair
#define pb push_back
#define int long long

using namespace std;
const int inf = 1e18;
const double EPS = 0.00000001;
const int mod = 1000000007;

signed main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int a;
    cin >> a;
    vector<set<int> > ss(26);
    for(int i =0;i<26;i++) ss[i].insert(n+1);
    for(int i =0;i<s.size();i++){
        ss[s[i]-'a'].insert(i);
    }
    while(a--){
        int t,x;
        cin >> t >> x;

        --x;
        if(t == 1){
            char y;
            cin >> y;
            ss[s[x]-'a'].erase(x);
            ss[y-'a'].insert(x);
            s[x] = y;
        }
        else{
            int cnt = 0;
            int y;
            cin >> y;
            --y;
            for(int i = 0;i<26;i++){
                int xx = *ss[i].lower_bound(x);
                if(xx <= y){
                    cnt++;
                }
            }
            cout << cnt << endl;
        }
    }
}


Measured memory_bytes: 27232
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N =  int(sys.stdin.readline())
L =  list(map(int, sys.stdin.readline().split()))

# 順方向と逆方向から計算したリストを保持しておく？
# 戻るときはリストの最も右の要素と原点とのdiffをとればいい

# 増加しなければスキップしてもかかる金額は変わらない

L = [0] + L + [0]
A = [abs(x - y) for x , y in zip(L, L[1::])]
SA = sum(A)

for i in range(1, N + 1):
    print(SA + abs(L[i + 1] - L[i - 1]) - (abs(L[i + 1] - L[i]) + abs(L[i] - L[i - 1])))

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

int main(){
  string s; cin >> s;
  if(s[s.size() - 1] == 's'){
    cout << s + "es" << endl;
  }
  else{
    cout << s + "s" << endl;
  }
  return 0;
}


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

using namespace std ;

int main()
{
	int n ;
	while( cin >> n ,n )
	{
		int m ;
		cin >> m ;
		int num[ n ] ;
		for( int i  = 0 ; i < n ; i++ )
			cin >> num[ i ] ;
		int ans = 0 ;
		for( int i  = 0 ; i < n ; i++ )
		{
			int cnt = 0 ;
			for( int j = i ; j < m + i && m + i < n ; j++ )
				cnt += num[ j ] ;
			ans = max( ans ,cnt ) ;
		}
		cout << ans << endl ;
	}
	return 0 ;
}

Measured memory_bytes: 3452
import java.util.Scanner;
public class Main{
    public static void main(String []args){
        Scanner sc=new Scanner(System.in);
        int a,b;
        a=sc.nextInt();
        b=sc.nextInt();
        int c=a*b;
        if(c%2==0){
            System.out.println("Even");
        }else if(c%2!=0){
            System.out.println("Odd");
        }
    }
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    int n,m; cin>>n>>m; cout<<((n==m)?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
N = int(input())
dp = [100000] * (N + 1)
dp[0] = 0
dp[1] = 1
for i in range(1, N + 1):
    dp[i] = dp[i - 1] + 1
    # 6
    prev = 6
    while i - prev >= 0:
        dp[i] = min(dp[i], dp[i - prev] + 1)
        prev *= 6
    # 9
    prev = 9
    while i - prev >= 0:
        dp[i] = min(dp[i], dp[i - prev] + 1)
        prev *= 9
print(dp[N])


Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  ll either = 0;
  ll sum = 0;
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
    if (i > 1) {
      either ^= A.at(i);
    }
    else {
      sum += A.at(i);
    }
  }
  ll both = sum - either;
  if (both % 2 == 1 || both >= A.at(0) * 2 + 1) {
    cout << -1 << "\n";
    return 0;
  }
  both /= 2;
  bitset<40> bs1(either);
  bitset<40> bs2(both);
  for (ll i = 0; i < 40; ++i) {
    if (bs1[i] == 1 && bs2[i] == 1) {
      cout << -1 << "\n";
      return 0;
    }
  }
  ll ans_small = 0;
  for (ll i = 40; i >= 0; --i) {
    if (bs1[i] == 1) {
      if (ans_small + pow(2, i) + both <= A.at(0)) {
        ans_small += pow(2, i);
      }
    }
  }
  if (both + ans_small == 0) {
    cout << -1 << "\n";
    return 0;
  }
  ll ans = A.at(0) - (both + ans_small);
  cout << ans << "\n";
}


Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
 
#define mo 1000000007
#define inf 1e18
#define rep(i, s, n) for (ll i = s; i < n; i = i + 1)
#define rrep(i,s,n) for(ll i=s;i>=n;i--)

ll mod(ll n) { return (n % (ll)mo + (ll)mo)%(ll)mo;}

int main(){
	ll n;cin>>n;
	vector<ll> a(n);
	rep(i,0,n) cin>>a[i];
	ll cnt = 0;
	rep(i,0,n){
		rep(j,i+1,n){
			rep(k,j+1,n){
				if(i!=j && j!=k && i!=k && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k]){
					//cout<<i<<" "<<j<<" "<<k<<endl;
					if(a[i]+a[j]>a[k] && a[i]+a[k]>a[j] && a[j]+a[k]>a[i]){
						cnt++;
						
						//cout<<i<<" "<<j<<" "<<k<<endl;
					}
				}
			}
		}
	}
	cout<<cnt;
	
}
		 

Measured memory_bytes: 3624
S = list(input())
A = []
j = 0
ans = 0
while j < len(S):
  i = S[j]
  if i == "A" or i == "C" or i == "G" or i == "T":
    ans += 1
    j += 1
  else:
    A.append(ans)
    ans = 0
    j += 1
if ans > 0:
    A.append(ans)
print(max(A))
    


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}
/*ll fact[200005];
ll komb(ll a, ll b){
	return (fact[a] * exp(fact[a-b] * fact[b], mod - 2)) % mod;
}*/
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n, a, b; cin>>n>>a>>b;
	/*fact[0] = 1;
	for(ll i = 1; i < 200005; i++){
		fact[i] = (fact[i-1] * i) % mod; 
	}*/
	ll sayi1 = 1, sayi2 = 1;
	for(ll i = 0; i < a; i++){
		sayi1 = (sayi1 * (n-i)) % mod;
	}
	for(ll i = 0; i < b; i++){
		sayi2 = (sayi2 * (n-i)) % mod;
	}
	ll fact1 = 1, fact2 = 1;
	for(ll i = 1; i <= a; i++) fact1 = (fact1 * i) % mod;
	for(ll i = 1; i <= b; i++) fact2 = (fact2 * i) % mod;
	//cout<<sayi2<<endl;
	cout<<(exp(2,n) - sayi1 * exp(fact1, mod-2)%mod - sayi2 * exp(fact2, mod-2)%mod - 1 + mod*3LL) % mod<<endl;
}


Measured memory_bytes: 256
#define pi 3.14159265358979323846

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    
    long double a, b, h, m;
    cin >> a >> b >> h >> m;
    //calculating deg
    long double hdeg = h*30;
    long double mdeg= m*6;
    hdeg+=mdeg/12;
    long double deg = abs(hdeg-mdeg);
    //apply law of cosines
    long double cosdeg = cos(deg* pi/180);
    long double asqr = a*a;
    long double bsqr= b*b;
    long double c = sqrt(asqr+bsqr-2*a*b*cosdeg);
    cout << fixed << showpoint;
    cout << setprecision(20);
    cout << c << endl;
    return 0;
}

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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main() {
    string s;cin>>s;
    ll ans1=-1;
    ll ans2=-1;
    for(ll i=1;i<s.size();i++){
        if(i==1){
            if(s[1]==s[0]){
                ans1=1;
                ans2=2;
            }
        }else{
            if(s[i]==s[i-1]){
                ans1=i;
                ans2=i+1;
            }else if(s[i]==s[i-2]){
                ans1=i-1;
                ans2=i+1;
            }
        }
    }
    cout<<ans1<<' '<<ans2<<endl;
    return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <map>

using namespace std;

int main() {
    int s; cin >> s;
    map<int, int> num; num[s]++;

    int pos = 1;
    while (1) {
        pos++;
        if (s%2) s = 3*s + 1;
        else s /= 2;
        if (num[s]) break;
        else num[s]++;
    }

    cout << pos << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>

using namespace std;

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


  int ans = INT_MAX;
  for(int i = 0; i < 26; i++){
    char cur_char = 'a' + i;
    if(S.find(cur_char) == string::npos){
      continue;
    }
    bool conseq_mode = false;
    int last_ind = -1;
    int tmp_ans = 0;
    for(int j = 0; j < S.size(); j++){
      if(conseq_mode){
        if(S[j] != cur_char){
          conseq_mode = false;
          last_ind = j - 1;
        }
      } else {
        if(S[j] == cur_char){
          conseq_mode = true;
          tmp_ans = max(tmp_ans, j - last_ind - 1);
        }
      }
    }
    if(!conseq_mode){
      tmp_ans = max(tmp_ans, (int)S.size() - last_ind - 1);
    }
    ans = min(ans, tmp_ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n;
	int a[100];
	int count = 0;
	int ans = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	for(int i = 1;i < n;i++){
		count++;
		if(a[i] == a[i - 1]){
		}else{
			ans += (count / 2);
			count = 0;
		}
	}
	count++;
	ans += (count / 2);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e7+4;
typedef long long ll;
int n;
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
ll ans;
int main() {
	n=read();
	for (register int i=1;i<=n;++i) {
		int cnt=n/i;
		int s=i,t=cnt*i;
		ans+=1ll*(s+t)*cnt/2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, m, x;
    cin >> n >> m >> x;

    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for(int i=0; i<n; i++){
        cin >> c[i];
        for(int j=0; j<m; j++){
            cin >> a[i][j];
        }
    }

    int min_mon = (1<<25);;
    for(int i=0; i<(1<<n); i++){
        vector<int> und(m, 0);
        int mon = 0;
        for(int j=0; j<n; j++){
            if(i & (1<<j)){
                mon += c[j];
                for(int k=0; k<m; k++){
                    und[k] += a[j][k];
                }
            }
        }

        // 判定
        bool flag = true;
        for(int k=0; k<m; k++){
            if(und[k] < x){
                flag = false;
                break;
            }
        }

        if(flag){
            min_mon = min(mon, min_mon);
        }
    }

    if(min_mon != (1<<25)){
        cout << min_mon << endl;
    }
    else{
        cout << -1 << endl;
    }

    return 0;
}

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

int main()
{
	int n,sum,i,sumsum=0;
	int array[11]={0};
	while(1){
		for(i=0;i<11;i++) array[i]=0;
		cin >> n;
		int loop = n;
		if(!n)break;
		while(loop--){
			sum = 0;
			for(i=0;i<n;i++){
				int x;
				cin >> x;
				cout << setw(5) << x;
				sum += x;
				array[i] += x;
			}
			cout << setw(5) << sum << "\n";
		}
		for(i=0;i<n;i++){
			cout << setw(5) << array[i];
			sumsum += array[i];
		}
	cout << setw(5) << sumsum << "\n";
	sumsum=0;
	}
	return 0;
}

Measured memory_bytes: 0
#ifdef _WIN32
#include <vector>
#include<set>
#include<map>
#include<stdio.h>
#include<iostream>
#else
#include <bits/stdc++.h>
#endif
using namespace std;

class Idx {
	public:
	set<int> pos_;
	void ins(int pos) {
		pos_.insert(pos);
	}
	void del(int pos) {
		pos_.erase(pos);
	}
	int ext(int pos1, int pos2) {
		auto it1 = pos_.lower_bound(pos1);
		auto it2 = pos_.upper_bound(pos2);
		return((it1 == it2) ? 0 : 1);
	}
};

int main() {
	int N, Nq;
	cin >> N; // 文字列の長さ
	char* S = new char[N];
	cin >> S; // 初期文字列

	// インデックス作成
	vector<Idx> idx(26); // a=0, ..., z=25 のインデックス
	for (int i = 0; i < N; i++) {
		int c = S[i] - 97;
		idx.at(c).ins(i + 1);
	}

	// クエリスタート
	cin >> Nq; // クエリ数
	int c1, c2;
	char* s3 = new char[7];
	for (int i = 0; i < Nq; i++) {
		cin >> c1 >> c2 >> s3;
		//		cout << "query " << c1 << " " << c2 << " " << s3 << endl;
		if (c1 == 1) { // type1
			int c_before = S[c2 - 1] - 97;
			int c_after = *s3 - 97;
			if (c_before != c_after) {
				idx.at(c_before).del(c2);
				idx.at(c_after).ins(c2);
			}
			S[c2 - 1] = *s3;
		}
		else { // c1==2: type2
			int count = 0;
			int c3 = atoi(s3);
			for (int j = 0; j < 26; j++) {
				count += idx.at(j).ext(c2, c3);
				//				cout << char(j + 97) << idx.at(j).ext(c2, c3) << " ";
			}
			cout << count << endl;
		}
	}
}

Measured memory_bytes: 26240
#include <iostream>
#include <string>
#include <map>


int main()
{
	std::map<char,std::string> enc1;
	enc1[' ']  = "101";
	enc1['\''] = "000000";
	enc1[',']  = "000011";
	enc1['-']  = "10010001";
	enc1['.']  = "010001";
	enc1['?']  = "000001";
	enc1['A']  = "100101";
	enc1['B']  = "10011010";
	enc1['C']  = "0101";
	enc1['D']  = "0001";
	enc1['E']  = "110";
	enc1['F']  = "01001";
	enc1['G']  = "10011011";
	enc1['H']  = "010000";
	enc1['I']  = "0111";
	enc1['J']  = "10011000";
	enc1['K']  = "0110";
	enc1['L']  = "00100";
	enc1['M']  = "10011001";
	enc1['N']  = "10011110";
	enc1['O']  = "00101";
	enc1['P']  = "111";
	enc1['Q']  = "10011111";
	enc1['R']  = "1000";
	enc1['S']  = "00110";
	enc1['T']  = "00111";
	enc1['U']  = "10011100";
	enc1['V']  = "10011101";
	enc1['W']  = "000010";
	enc1['X']  = "10010010";
	enc1['Y']  = "10010011";
	enc1['Z']  = "10010000";
	
	std::map<std::string,char> enc2;
	enc2["00000"] = 'A';
	enc2["00001"] = 'B';
	enc2["00010"] = 'C';
	enc2["00011"] = 'D';
	enc2["00100"] = 'E';
	enc2["00101"] = 'F';
	enc2["00110"] = 'G';
	enc2["00111"] = 'H';
	enc2["01000"] = 'I';
	enc2["01001"] = 'J';
	enc2["01010"] = 'K';
	enc2["01011"] = 'L';
	enc2["01100"] = 'M';
	enc2["01101"] = 'N';
	enc2["01110"] = 'O';
	enc2["01111"] = 'P';
	enc2["10000"] = 'Q';
	enc2["10001"] = 'R';
	enc2["10010"] = 'S';
	enc2["10011"] = 'T';
	enc2["10100"] = 'U';
	enc2["10101"] = 'V';
	enc2["10110"] = 'W';
	enc2["10111"] = 'X';
	enc2["11000"] = 'Y';
	enc2["11001"] = 'Z';
	enc2["11010"] = ' ';
	enc2["11011"] = '.';
	enc2["11100"] = ',';
	enc2["11101"] = '-';
	enc2["11110"] = '\'';
	enc2["11111"] = '?';
	
	std::string buf;
	while (std::getline(std::cin, buf)) {
		std::string after_enc1 = "";
		for (int i=0; i<buf.length(); i++) {
			after_enc1 += enc1[buf[i]];
		}
		std::string after_enc2 = "";
		for (int offset=0; offset<after_enc1.length(); offset+=5) {
			std::string tmp = after_enc1.substr(offset, 5);
			while (tmp.length()<5) tmp += "0";
			after_enc2 += enc2[tmp];
		}
		std::cout << after_enc2 << std::endl;
	}

	return 0;
}
			



Measured memory_bytes: 3172
#include<bits/stdc++.h>
#include<unordered_map>
#define M 1000000007
#define T 998244353
#define PI 3.142
#define ll long long

using namespace std;

int ldp[3001][3001];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     
    string s, t;
    cin >> s >> t;
    int i, j;
    for(i=0; i<3001; i++){
        ldp[0][i]=0;
        ldp[i][0]=0;
    }
    for(i=1; i<=s.length(); i++){
        for(j=1; j<=t.length(); j++){
            if(s[i-1]==t[j-1]){
                ldp[i][j] = ldp[i-1][j-1]+1;
            }
            else {
                if(ldp[i-1][j]>ldp[i][j-1]){
                    ldp[i][j] = ldp[i-1][j];
                }
                else {
                    ldp[i][j]=ldp[i][j-1];
                }
            }
        }
    }
    i = s.length();
    j = t.length();
    int ml = ldp[i][j];
    char d[ml];
    int ind = ml-1;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            d[ind]=s[i-1];
            i--; j--; ind--;
        }
        else if(ldp[i-1][j]>ldp[i][j-1]){
            i--;
        }
        else {
            j--;
        }
    }
    for(i=0; i<ml; i++){
        cout << d[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 35456
#include <stdio.h>
int main(){
	int r,c;
	int i,j;
	int v[101][101] = {{0}};
	scanf("%d %d",&r,&c);

	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			int buf;
			scanf("%d",&buf);
			v[i][j] = buf;
			v[i][c] += buf;
		}
	}

	for(i=0;i<c;i++){
		for (j=0;j<r;j++){
			v[r][i] += v[j][i];
		}
		v[r][c] += v[r][i];
	}


	for(i=0;i<r+1;i++){
		for(j=0;j<c;j++){
			printf("%d ",v[i][j]);
		}
		printf("%d\n",v[i][c]);
	}
}

Measured memory_bytes: 1076
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        List<int> a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToList();
        a.Insert(0, 0);
        a.Add(0);
        List<int> gap = new List<int>();
        for (int i = 1; i < a.Count; i++)
        {
            gap.Add(Math.Abs(a[i] - a[i - 1]));
        }
        long ans = gap.Sum();

        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        for (int i = 0; i < n; i++)
        {
            Console.WriteLine(ans - gap[i + 1] - gap[i] + Math.Abs(a[i + 2] - a[i]));
        }
        Console.Out.Flush();
    }
}

Measured memory_bytes: 28764
#!/usr/bin/env python3.4
# -*- coding: utf-8 -*-

# abc124_b

# input
n = int(input())
Hs = [int(s) for s in input().split()]
# output
m = -1
count = 0
for h in Hs:
    if h>=m:
        m = h
        count += 1
ans = count
print(ans)



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

int main() {
  int N;
  cin >> N;
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i).first;
    A.at(i).second = i + 1;
  }

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

  for (auto a : A) {
    cout << a.second << "\n";
  }
}

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

using namespace std;

int main(){
	string str;

	cin >> str;

	if (str.size() == 2){
		cout << str[0] << str[1] << endl;
	}
	else if (str.size() == 3){
		cout << str[2] << str[1] << str[0] << endl;

	}

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            if(N == 25)
            {
                Console.WriteLine("Christmas");
            }
            else if (N == 24)
            {
                Console.WriteLine("Christmas Eve");
            }
            else if (N == 23)
            {
                Console.WriteLine("Christmas Eve Eve");
            }
            else
            {
                Console.WriteLine("Christmas Eve Eve Eve");
            }
        }
    }
}


Measured memory_bytes: 13140
import math
n =int(input())
X=list(map(int, input().split()))
Y=list(map(int, input().split()))
s1=0
s2=0
s3=0
s4=[]
for i in range(n):
  s1 += abs(X[i]-Y[i])
  s2 += (abs(X[i]-Y[i])**2)
  s3 += (abs(X[i]-Y[i])**3)
  s4.append(abs(X[i]-Y[i]))
#print(s4)
s4max = max(s4)
  
print('{:.6f}'.format(s1))
print('{:.6f}'.format(math.sqrt(s2)))
print('{:.6f}'.format(math.pow(s3,1/3)))
print('{:.6f}'.format(s4max))


Measured memory_bytes: 5696
N = int(input())
l = list(map(int,input().split()))
l.sort(reverse=True)

al=list()
bl=list()

i = 0
j = 0
while 2*i < N:
    al.append(l[2*i])
    i = i + 1
while 2*j+1 < N:
    bl.append(l[2*j+1])
    j = j+1
    
print(sum(al)-sum(bl))

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

long dx[] = {1, 0, -1, 0};
long dy[] = {0, 1, 0, -1};
using pll = pair<long, long>;
const long MOD = 1000000007;

int main() {
	long h, w, ch, cw, dh, dw;
	cin >> h >> w >> ch >> cw >> dh >> dw;
	ch--; cw--; dh--; dw--;
	vector<string> m(h);
	for (auto& item: m) cin >> item;
	vector<vector<long>> dist(h, vector<long>(w, LONG_MAX));
	deque<pll> q;
	q.emplace_front(ch, cw);
	dist[ch][cw] = 0;
	while(!q.empty()) {
		long y = q.front().first;
		long x = q.front().second;
		long cost = dist[y][x];
		q.pop_front();
		if (dist[y][x] != cost) continue;
		for (long i = 0; i < 4; i++) {
			long nx = x + dx[i];
			long ny = y + dy[i];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
			if (m[ny][nx] == '#') continue;
			if (dist[ny][nx] <= cost) continue;
			dist[ny][nx] = cost;
			q.emplace_front(ny, nx);
		}
		for (long i = -2; i <= 2; i++) {
			for (long j = -2; j <= 2; j++) {
				long ny = y + i;
				long nx = x + j;
				if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
				if (m[ny][nx] == '#') continue;
				if (dist[ny][nx] <= cost+1) continue;
				dist[ny][nx] = cost+1;
				q.emplace_back(ny, nx);
			}
		}
	}

	long ans = dist[dh][dw];
	if (ans == LONG_MAX) ans = -1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12688
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;cin>>n>>m;
  priority_queue<ll>que;
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    que.push(a);
  }
  for(int i=0;i<m;i++){
    ll now=que.top();
    que.pop();
    now/=2;
    que.push(now);
  }
  ll ans=0;
  while(!que.empty()){
    ans+=que.top();
    que.pop();
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1400
n=int(input())
hoge=[[0 for i in range(3)] for j in range(n+1)]

for i in range(1,n+1):
  a,b,c=map(int,input().split())
  hoge[i][0]=max(hoge[i-1][1]+a,hoge[i-1][2]+a)
  hoge[i][1]=max(hoge[i-1][0]+b,hoge[i-1][2]+b)
  hoge[i][2]=max(hoge[i-1][0]+c,hoge[i-1][1]+c)
  
print(max(hoge[-1]))

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

int main(){
    int mx,score[2]={},input;
    for(int i=0;i<2;i++){
        for(int j=0;j<4;j++){
            cin>>input;
            score[i]+=input;
        }
    }
    mx=(score[0]>score[1])?score[0]:score[1];
    printf("%d\n",mx);
    return 0;
}

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

int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }
    sort(all(a));

    int tmp = a[0];
    bool ok = true;
    REP(i, 1, n){
        if(tmp == a[i]){
            ok = false;
            break;
        }
        tmp = a[i];
    }
    
    if(ok){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#stable sort Taka
def bubble_sort(c, n):
    for i in range(n):
        for j in range(n-1, i, -1):
            if int(c[j][1]) < int(c[j-1][1]):
                c[j], c[j-1] = c[j-1], c[j]
    return c

def selection_sort(c, n):
    for i in range(n):
        minj = i
        for j in range(i, n):
            if int(c[j][1]) < int(c[minj][1]):
                minj = j
        c[i], c[minj] = c[minj], c[i]
    return c

def is_stable(original_list, sorted_list):
    for target in sorted_list:
        for original in original_list:
            #print(target, original)
            if target[1] == original[1]:
                if target[0] != original[0]:
                    return "Not stable"
                original_list.remove(original)
                break
    return "Stable"

if __name__ == "__main__":
    import copy
    n = int(input())
    c = input().split()
    bubble_list = bubble_sort(copy.deepcopy(c), n)
    print(*bubble_list)
    print(is_stable(copy.deepcopy(c), bubble_list))
    selection_list = selection_sort(copy.deepcopy(c), n)
    print(*selection_list)
    print(is_stable(copy.deepcopy(c), selection_list))


Measured memory_bytes: 6344
#include <algorithm>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/

vector<long long> ok(0);

void dfs(long long i, bool three, bool five, bool seven) {
  if (i > 1e9) return ;
  else if (three && five && seven) {
    ok.push_back(i);
    dfs(i * 10 + 3, true, true, true);
    dfs(i * 10 + 5, true, true, true);
    dfs(i * 10 + 7, true, true, true);
  } else if (three && five) {
    dfs(i * 10 + 3, true, true, false);
    dfs(i * 10 + 5, true, true, false);
    dfs(i * 10 + 7, true, true, true);
  } else if (three && seven) {
    dfs(i * 10 + 3, true, false, true);
    dfs(i * 10 + 5, true, true, true);
    dfs(i * 10 + 7, true, false, true);
  } else if (five && seven) {
    dfs(i * 10 + 3, true, true, true);
    dfs(i * 10 + 5, false, true, true);
    dfs(i * 10 + 7, false, true, true);
  } else if (three) {
    dfs(i * 10 + 3, true, false, false);
    dfs(i * 10 + 5, true, true, false);
    dfs(i * 10 + 7, true, false, true);
  } else if (five) {
    dfs(i * 10 + 3, true, true, false);
    dfs(i * 10 + 5, false, true, false);
    dfs(i * 10 + 7, false, true, true);
  } else if (seven) {
    dfs(i * 10 + 3, true, false, true);
    dfs(i * 10 + 5, false, true, true);
    dfs(i * 10 + 7, false, false, true);
  } else {
    dfs(3, true, false, false);
    dfs(5, false, true, false);
    dfs(7, false, false, true);
  }
  return ;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  dfs(0, false, false, false);
  int ans = 0;
  for (long long aa : ok) if (aa <= n) ++ans;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 640
#define DINGER_GISBAR
#include <bits/stdc++.h>
using namespace std;
const long long MOD = static_cast<int>(1e9) + 7;
//{{{TEMPLATE_BEGIN
#include <unistd.h>
using namespace std::rel_ops;
#ifdef ZEROKUGI
#include <dumper.hpp>
#define dump(x) dumper::dumper(cerr, __LINE__, (#x), (x), 50, 1, 1)
#define tick(...) dumper::tick(__VA_ARGS__)
#pragma message "Compiling " __FILE__
#else
#define dump(x)
#define tick(...)
#endif
typedef long long lint;
typedef unsigned long long ulint;
typedef long double ldouble;
typedef vector<int> vint;
#define rep(i, n) \
    for (int i = 0, i##_len = static_cast<int>(n); i < i##_len; i++)
#define all(c) begin(c), end(c)
#define perm(c)   \
    sort(all(c)); \
    for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))
#define uniquenize(v) (v).erase(unique(all(v)), end(v))
#define cauto const auto &
#define memset(x, y) memset(x, y, sizeof(x))
#define popcount __builtin_popcount
#define gcd __gcd
inline lint bit(int x) { return 1LL << x; }
template <class T>
inline int size(const T& a) {
    return (int)a.size();
}
template <class T>
inline bool chmin(T& a, const T& b) {
    return a > b ? a = b, 1 : 0;
}
template <class T>
inline int clamp(T v, T lo, T hi) {
    return (v > hi) - (v < lo);
}
template <class T>
inline bool chmax(T& a, const T& b) {
    return a < b ? a = b, 1 : 0;
}
template <class T>
inline pair<vector<T>, char> operator*(const vector<T>& v, const char& c) {
    return make_pair(v, c);
}
template <class T>
inline istream& operator>>(istream& is, vector<T>& v) {
#ifdef ZEROKUGI
    if (v.empty()) {
        cerr << "Error L" << __LINE__ << ": vector size is zero." << endl;
        exit(EXIT_FAILURE);
    }
#endif
    for (auto& x : v) is >> x;
    return is;
}
template <class T>
inline ostream& operator<<(ostream& os, const pair<vector<T>, char>& v) {
    bool t = 0;
    for (const T& x : v.first) {
        if (t) os << v.second;
        os << x;
        t = 1;
    }
    return os;
}
template <class T>
inline ostream& operator<<(ostream& os, vector<T>& v) {
    return os << v * ' ';
}
struct before_main {
    before_main() {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
        tick(0, 0);
    };
} __before_main;
//}}}TEMPLATE_END

int n, e, w, s;
int main() {
    string str;
    cin >> str;

    for (char c : str) {
        if (c == 'N') n = 1;
        if (c == 'E') e = 1;
        if (c == 'W') w = 1;
        if (c == 'S') s = 1;
    }
    bool ok = true;
    ok &= (n + s) != 1;
    ok &= (e + w) != 1;
    cout << (ok ? "Yes" : "No") << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl);
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){cout << "Yes" << endl;}
inline void No(){cout << "No" << endl;}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){cout << "YES" << endl;}
inline void NO(){cout << "NO" << endl;}
inline void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}
template<typename T> ostream& operator<<(ostream& s, const set<T>& st) {
    int len = st.size();
    s << '{';
    int i = 0;
    for (auto x : st) {
        s << x; if (i < len-1) s << ", ";
        ++i;
    }
    s << '}';
    return s;
}
struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

vector<pint> key;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    key.resize(m);
    rep(i, m){
        int a, b;
        scanf("%d%d", &a, &b);
        key[i].second = a;
        rep(j, b){
            int c; scanf("%d", &c); --c;
            key[i].first |= 1<<c;
        }
    }

    vector<int> dp(1<<n, INF);
    dp[0] = 0;
    rep(s, 1<<n){
        rep(i, m){
            chmin(dp[s|key[i].first], dp[s]+key[i].second);
        }
    }
    int ans = dp.back();
    if(ans == INF) ans = -1;
    ppp(ans);
    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <complex>
#include <vector>
#include <cstdio>
#define X real()
#define Y imag()
#define EPS (1e-10)
using namespace std;

typedef complex<double> Point; // 点
typedef Point Vector; // ベクトル

struct Segment{ // 線分
  Point p1, p2;
  Segment(){};
  Segment(Point p1, Point p2) : p1(p1), p2(p2) {}; // p1,p2をセット
};

typedef Segment Line; // 直線

typedef vector<Point> Polygon; // 多角形

double dotproduct(Vector a, Vector b) // 内積
{
  return real((conj(a) * b));
}

double crossproduct(Vector a, Vector b) // 外積
{
  return imag(conj(a) * b);
}

double dist(Point p1, Point p2) // 二点間の距離
{
  return abs(p1 - p2);
}

Point project(Line l, Point p){ // 射影
  double r = dotproduct(p - l.p1, l.p2 - l.p1) / norm(l.p2 - l.p1);
  return l.p1 + (l.p2 - l.p1) * r;
}

Point reflect(Line l, Point p){
  return p + (project(l, p) - p) * 2.0;
}

#define EQ(a, b) (abs((a) - (b)) < EPS) // 二つのスカラーが等しいかどうか
#define EQV(a, b) (EQ((a).X, (b).X) && EQ((a).Y, (b).Y)) // 二つのベクトルが等しいかどうか

int main()
{
  Point p, q;
  cin >> p.X >> p.Y >> q.X >> q.Y;
  Line l(p,q);
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    Point x;
    cin >> x.X >> x.Y;
    printf("%.10lf %.10lf\n", reflect(l, x).X, reflect(l, x).Y);
  }
}

Measured memory_bytes: 1268
#include<stdio.h>

int main()
{
  int a,b,x,balance;
  
  scanf("%d",&x);
  scanf("%d",&a);
  scanf("%d",&b);
  
  balance = x;
  balance -= a;
  do{
    balance -= b;
  }while(balance / b != 0);
  
  printf("%d",balance);
 
  return 0;
}

Measured memory_bytes: 128