akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;//998244353;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template<class _T> static void getint(_T& a) {
	if (sizeof(_T) > sizeof(int)) {
		scanf("%lld", &a);
	}
	else {
		scanf("%d", &a);
	}
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

class data {
public:
	int a, b, c, d;
};

static int dfs(std::vector<int> An, int M, int N, std::vector<data>& qi)
{
	int val = 0;
	if (An.size() == N) {
		int Q = qi.size();
		for (int q = 0; q < Q; q++) {
			if (An[qi[q].b] - An[qi[q].a] == qi[q].c) {
				val += qi[q].d;
			}
		}
	}
	else {
		int idx = An.size();
		int last = 1;
		if (idx) {
			last = *An.rbegin();
		}
		An.push_back(0);
		for (int num = last; num <= M; num++) {
			An[idx] = num;
			val = std::max(val, dfs(An, M, N, qi));
		}
	}
	return val;
}


static void exec()
{
	int N, M, Q;
	get(N, M, Q);

	std::vector<data> qi(Q);
	for (int i = 0; i < Q; i++) {
		get(qi[i].a, qi[i].b); qi[i].a--; qi[i].b--;
		get(qi[i].c, qi[i].d);
	}

	printf("%d\n", dfs(std::vector<int>(), M, N, qi));
}


Measured memory_bytes: 3732
from sys import stdin, stdout # only need for big input

max_honest = 0
testomonies = []
state = []

def dfs(person):
    global max_honest
    if person >= len(state):
        correctState = True
        for p in range(len(state)):
            if state[p] == 1:
                for t in testomonies[p]:
                    x, y = t
                    if state[x] != y:
                        correctState = False
                        break
        if correctState:
            sum = 0
            for s in state:
                sum += s
            max_honest = max(max_honest, sum)
        return

    state[person] = 0
    dfs(person + 1)

    state[person] = 1 
    dfs(person + 1)
    

def solve():
    global state
    n = int(stdin.readline())
    for _ in range(n):
        a = int(stdin.readline())
        t = []
        for _ in range(a):
            x, y = [int(inp) for inp in stdin.readline().split()]
            t.append((x - 1,y))
        testomonies.append(t)
    # print(testomonies)
    state = [-1] * n
    dfs(0)
    print(max_honest)


def main():
    solve()


if __name__ == "__main__":
    main()

Measured memory_bytes: 71384
from collections import defaultdict
N, M = map(int, input().split())
A = [int(i) for i in input().split()]

d = defaultdict(int)

s = 0
for i in range(N):
    d[s % M] += 1
    s += A[i]
d[s % M] += 1


ans = 0
for v in d.values():
    ans += v*(v-1)//2
print(ans)


Measured memory_bytes: 62576
def digit_10(n):
    dten = 0
    while(n>0):
        dten+=int(n%10)
        n/=10
    return dten

n = int(input())
l = []
for a in range(1,n):
    l.append(digit_10(a)+digit_10(n-a))
print(min(l))

Measured memory_bytes: 46428
N = int(input())
A = sorted(map(int,input().split(" ")))

while N > 1:
    a = A[0]
    b = A[1] % a
    if b == 0:
        A.pop(1)
        N -= 1
    else:
        A[1] = a
        A[0] = b

print(A[0])

Measured memory_bytes: 14224
import java.util.*;

public class Main{
    public static void main(String[] args){
    //入力
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] H = new int[N];
        int[] L = new int[N-1];
        for(int i=0; i<N; i++){
            H[i] = sc.nextInt();
        }
        for(int j=N-2;j>=0;j--){
            if(j<N-2){
                L[j] = Math.min(L[j+1],H[j+1]);
            }
            else{
                L[j] = H[j+1];
            }
        }
    //処理
        boolean b = true;
        for(int i=0;i<N-1;i++){
            if(H[i]-1>L[i]){
                b = false;
            }
        }
        System.out.println((b)?"Yes":"No");
        sc.close();

    }
}

Measured memory_bytes: 50412
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


x,y=map(int,input().split())
s=int((2*y-x)/3)
t=int((2*x-y)/3)
if (2*y-x)%3!=0 or (2*x-y)%3!=0:
    print(0)
elif s<0 or t<0:
    print(0)
else:
    a = cmb(s+t, t)
    print(a%(10**9+7))

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

#include <algorithm>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;
typedef long long ll;
typedef pair<ll, ll> P;
#define REP(i, n) for (long long i = 0; i < (n); i++)
const ll INF = 1LL << 60;
vector<vector<ll>> adj;
bool warfloyd(vector<vector<ll>> graph) {
    for (int k = 0; k < graph.size(); k++) {
        for (int i = 0; i < graph.size(); i++) {
            for (int j = 0; j < graph.size(); j++) {
                adj[i][j] = min(adj[i][j], adj[i][k] + adj[k][j]);
            }
        }
    }
    REP(i, graph.size()) {
        if (adj[i][i] != 0) {
            return true;
        }
    }
    return false;
}
int main() {
    int n, m, r;
    cin >> n >> m >> r;
    vector<int> city(r);
    vector<int> save(r);
    REP(i, r) {
        cin >> city[i];
        city[i]--;
    }
    save = city;
    next_permutation(city.begin(), city.end());
    adj.resize(n, vector<ll>(n, INF));
    REP(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        adj[a][b] = c;
        adj[b][a] = c;
    }
    warfloyd(adj);
    int mn = 1e9;
    while (city != save) {
        int sum = 0;
        REP(i, city.size() - 1) { sum += adj[city[i]][city[i + 1]]; }
        mn = min(sum, mn);
        // for (auto x : city) {
        //     cout << x + 1;
        // }
        // cout << endl;
        // cout << sum << endl;
        next_permutation(city.begin(), city.end());
    }
    int sum = 0;
    REP(i, save.size() - 1) { sum += adj[save[i]][save[i + 1]]; }
    mn = min(sum, mn);
    cout << mn << endl;
}

Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
 int main() {
   string A,B,C;
   cin >>A>>B>>C;
  if(A.at(A.size()-1)==B.at(0) && B.at(B.size()-1)==C.at(0)) cout<<"YES"<<endl;
   else cout<<"NO"<<endl;
   }

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

int main() {
    int N;
    cin >> N;
    vector<tuple<string, int, int>> a;
    FOR(i, 1, N + 1) {
        string S;
        int P;
        cin >> S >> P;
        P = -P;
        a.push_back(tie(S, P, i));
    }
    sort(a.begin(), a.end());
    rep(i, N) cout << get<2>(a[i]) << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3","sse2","sse")
#pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC diagnostic error "-std=c++14"
#include "bits/stdc++.h"
//#include "ext/pb_ds/tree_policy.hpp"
//#include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) (x&(-x))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9+7;
const ll inf = 1e9+7;
const ld eps = 1e-9;
const db PI = atan(1)*4;
template<typename T>
inline int sign(const T&a) {
    if(a<0)return -1;
    if(a>0)return 1;
    return 0;
}

template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}

template<typename T> inline void in(T &x) {
    x = 0;
    T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (isdigit(ch))  {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    x *= f;
}

ll twop(int x) {
    return 1LL<<x;
}

template<typename A,typename B > inline void in(A&x,B&y) {
    in(x);
    in(y);
}
template<typename A,typename B,typename C>inline void in(A&x,B&y,C&z) {
    in(x);
    in(y);
    in(z);
}
template<typename A,typename B,typename C,typename D> inline void in(A&x,B&y,C&z,D&d) {
    in(x);
    in(y);
    in(z);
    in(d);
}

deque<ll>q;
ll sum = 0;
void solve(){
    if(!sz(q))return;
    REP(i,0,sz(q)-1){
        if(q[i]%2==1){
            q[i]--;
            q[i+1]--;
            sum++;
        }
        sum+=q[i]/2;
    }
    sum+=q.back()/2;
    q.clear();
}

int main(){
    int n;in(n);
    REP(i,0,n){
        ll c;in(c);
        if(c == 0){
            solve();
        }else{
            q.PB(c);
        }
    }
    solve();
    cout<<sum;
    return 0;
}


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

int main() {
  int N;
  ll H[100005];
  cin >> N;
  rep(i, N) { cin >> H[i]; }

  ll count = 0;
  ll tmp = 0;
  for (int i = 0; i < N - 1; i++) {
    if (H[i] >= H[i + 1]) {
      tmp += 1;
    } else {
      count = max(count, tmp);
      tmp = 0;
    }
  }
  count = max(count, tmp);
  cout << max(count, tmp) << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
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 << endl; }
 
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(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
 
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

const int INF = (int)1e9;
const int maxN = 51;

void solve() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = min(n, b - 1);
  ll ans = (a * x) / b;
  cout << ans;
}
 
int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
 
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
using namespace std;


signed main(){
	fast
	
	int t, d; cin>>t>>d;
	int arr[t][2];
	int c=0;
	
	for(int i=0; i<t; i++){
		cin>>arr[i][0]>>arr[i][1];
		int dis= arr[i][0]*arr[i][0] + arr[i][1]*arr[i][1];
		if(d*d >= dis){
			c++;
		}
	}
	
	cout<<c;
return 0; 
}

Measured memory_bytes: 6736
#! -*- coding:utf-8 -*-
N,T = map(int,input().split())
t = input()

t = t.split()
for i in range(len(t)):
    t[i] = int(t[i])

total = 0
for i in range(len(t)-1):
    if t[i+1] - t[i] >= T:
        total += T
    else:
        total += t[i+1] - t[i]
total += T
print(total)

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


int main(){
  
  
  long long x;
  cin>>x;
  int flag = 0;
  int A,B;
  for(int i=-1000 ;i<=1000;i++){
   for(int j=-1000;j<=1000;j++){
    long long a=i,b=j;
	A = a;
	B = b;
     for(int k=1;k<=4;k++){
      a = a*i;
       b = b*j;
     }
	 //A =a;
	 //B = b;
     if(a - b == x){
      cout<<A<<" "<<B<<endl;
       return 0;
     }
   }
  }
  //cout<<A<<" "<<B<<endl;
  
  
  
  
 //return 0; 
  
  
}

Measured memory_bytes: 3628
/*
* Created by: WeirdBugsButOkay
*/

#include <bits/stdc++.h>

#define ll long long
#define ld long double
#define ff first
#define ss second

using namespace std;

void solve()
{
    ll k, n;
    cin >> n >> k;
    ll inf = 1000000007;
    ll a[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    vector <ll> neg, pos;
    for(ll i = 0; i < n; i++)
        if(a[i] < 0)
            neg.push_back(a[i]);
        else pos.push_back(a[i]);
    sort(neg.begin(), neg.end());
    sort(pos.rbegin(), pos.rend());
    if(pos.size() == 0 && k % 2 == 1)
    {
        ll ans = 1;
        reverse(neg.begin(), neg.end());
        for(ll i = 0; i < k; i++)
            ans = (ans * (-neg[i])) % inf;
        ans = (inf - ans) % inf;
        cout << ans << endl;
        return;
    }
    if(n == k)
    {
        ll ans = 1;
        bool neg = 0;
        for(ll i = 0; i < n; i++)
        {
            ans = (ans * abs(a[i])) % inf;
            neg ^= (a[i] < 0);
        }
        if(neg)
            ans = (inf - ans) % inf;
        cout << ans << endl;
        return;
    }
    ll cnt = max(0ll, k - (ll)pos.size());
    if(cnt % 2 == 1)
        cnt++;
    ll rc = k - cnt;
    //cout << cnt << " " << rc << endl;
    while(cnt + 1 < (ll)neg.size() && cnt + 1 < k)
    {
        ll np = neg[cnt] * neg[cnt + 1];
        ll pp = pos[rc - 1] * pos[rc - 2];
        if(pp >= np)
            break;
        else
        {
            rc -= 2;
            cnt += 2;
        }
    }
    ll ans = 1;
    for(ll i = 0; i < rc; i++)
        ans = (ans * pos[i]) % inf;
    for(ll i = 0; i < cnt; i++)
        ans = (ans * (-neg[i])) % inf;
    cout << ans << endl;
}

int main()
{
    int q = 1;
    //scanf("%d", &q);
    for(int i = 1; i <= q; i++)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 6884
import sys
from itertools import combinations

def add_combination(S, cmb):
    new_S = ""

    for i in range(len(S)):
        new_S += S[i]
        if i in cmb:
            new_S += "+"

    return eval(new_S)


S = input()
sum_S = int(S)

for i in range(1, len(S)):
    for cmb in combinations(range(len(S) - 1), i):
        sum_S += add_combination(S, cmb)

print(sum_S)

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdlib.h>
#include<set>
#include<math.h>
#include<iomanip>

using namespace std;

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

int main(void)
{
    int n;
    cin>>n;
    
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int b[n],c[n];
    b[0]=a[0];
    c[n-1]=a[n-1];
    for(int i=1;i<n;i++){
        b[i]=gcd(b[i-1],a[i]);
    }
    for(int i=n-2;i>=0;i--){
        c[i]=gcd(c[i+1],a[i]);
    }
    
    int ans=1;
    if(b[n-2]>ans){
        ans=b[n-2];
    }
    if(c[1]>ans){
        ans=c[1];
    }
    for(int i=1;i<n-1;i++){
        int num=gcd(b[i-1],c[i+1]);
        if(num>ans){
            ans=num;
        }
    }
    cout<<ans<<endl;
    
}


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

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
    }
    vector<ll> dp(100001, 0);
    for (ll i = 0; i < N; i++)
    {
        for (ll j = W; j >= w[i]; j--)
        {
            chmax(dp[j], dp[j - w[i]] + v[i]);
        }
    }
    cout << dp[W] << endl;
}

Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc110/tasks/abc110_b
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

#define FOR(i, n) for (int i = 0; i < n; i++)
#define EACH(i, n) for (auto &i: n)

void solv(int n, int m, int x, int y) {
  vector<int> xx(n + 1), yy(m + 1);

  FOR(i, n) {
    cin >> xx[i];
  }
  xx[n] = x;
  FOR(i, m) {
    cin >> yy[i];
  }
  yy[m] = y;

  int x_max = *max_element(xx.begin(), xx.end());
  int y_min = *min_element(yy.begin(), yy.end());
  if (x_max >= y_min) {
    cout << "War" << endl;
  } else {
    cout << "No War" << endl;
  }
}

int main() {
  int n, m, x, y;

  while (cin >> n >> m >> x >> y) {
    solv(n, m, x, y);
  }

  return 0;
}


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

int main() {
	int w, n;
	int u[30];
	cin >> w >> n;
	for (int i = 0; i < w; i++) {
		u[i] = i + 1;
	}
	for (int i = 0; i < n; i++) {
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(u[a - 1], u[b - 1]);
	}
	for (int i = 0; i < w; i++) {
		cout << u[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
from sys import setrecursionlimit

setrecursionlimit(10**6)
def recur(N_:int,limit:int):
    if N_ > limit:
        return 0
    else:
        tmp = str(N_)
        if ("3" in tmp) and ("5" in tmp) and ("7" in tmp):
            N_ *= 10
            return recur(N_ + 3,limit) + recur(N_ + 5,limit) + recur(N_ + 7,limit) + 1
        else:
            N_ *= 10
            return recur(N_ + 3,limit) + recur(N_ + 5,limit) + recur(N_ + 7,limit)


def main():
    N = int(input())
    ans = recur(3,N) + recur(5,N) + recur(7,N)
    print(ans)
    return   

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  int s = 0;
  rep(i, H) {
    cin >> S[i];
    rep(j, W) if(S[i][j] == 'S') s = i*W+j;
  }
  vector<int> d(H*W);
  vector<bool> vis(H*W);
  set<int> se;
  auto bfs = [&]() {
    int dx[] = {-1, 0, 1, 0};
    int dy[] = {0, 1, 0, -1};
    queue<int> q;
    q.push(s);
    while(!q.empty()) {
      int cur = q.front(); q.pop();
      int x = cur/W;
      int y = cur%W;
      if(vis[cur]) continue;
      vis[cur] = true;
      se.insert(cur);
      rep(k, 4) {
        int nx = x+dx[k];
        int ny = y+dy[k];
        if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
        if(S[nx][ny] == '#') continue;
        int ne = nx*W+ny;
        if(vis[ne]) continue;
        if(d[cur]>=K) continue;
        d[ne] = d[cur]+1;
        q.push(ne);
      }
    }
  };
  bfs();
  int ans = inf;
  for(auto s: se) {
    int x = s/W;
    int y = s%W;
    int mn = min({x, y, H-1-x, W-1-y});
    ans = min((mn+K-1)/K+1, ans);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 35920
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] s = saori.nextHayami().split("");
		if(s.length == 2){
			for(int i = 0;i < s.length;i++){
				System.out.print(s[i]);
			} 
		} else {
			for(int i = s.length - 1;i >= 0;i--){
				System.out.print(s[i]);
			}
		}
		System.out.println("");
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>


signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int H,W, h,w;
  cin >> H >>W>> h >>w;
  cout << (H-h)*(W-w) << endl;
  ret;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
  	cin>>s;
  	int sum=0;
  	for(int i=0;i<s.length();i++)
    {
      sum+=(s[i]-48);
    }
  	if(sum%9==0)
      cout<<"Yes"<<endl;
  	else cout<<"No"<<endl;
}

Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<string.h>
#include<math.h>
using namespace std;
#define N 100000
int n;
int a[2];
int main() {
	cin >> n;
	int in;
	for (int i = 0; i < n; i++) {
		cin >> in;
		a[in % 2]++;
	}
	if (a[1] % 2)
		cout << "NO" << endl;
	else
		cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    REP(i,n) cout << s[i] << t[i];

    return 0;
}

Measured memory_bytes: 3600
S = input()

if len(S) % 2 == 0:
    front = S[:len(S)//2]
    back = S[len(S)//2:][::-1]

else:
    front = S[:len(S)//2]
    back = S[len(S)//2+1:][::-1]

ans = 0
for i, j in zip(front, back):
    if i != j:
        ans += 1

print(ans)


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

typedef long long ll;

ll llabs(ll x){
	if(x<0) return -x;
	else return x;
}

int main(){
	ll x,y;
	cin>>x>>y;
	if(llabs(x-y)<=1) cout<<"Brown\n";
	else cout<<"Alice\n";
}

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

int main(){
  string s;long long int k;
  cin>>s>>k;
  if(s.at(0)!='1'){cout<<s.at(0);}
  else {
    long long int x=0;
    char y='0';
    rep(i,s.size()){
      if(s.at(i)=='1'){x++;}
      else{y=s.at(i);break;}
    } 
    if(k<=x)cout<<1;
    else{cout<<y;}
  }
}



Measured memory_bytes: 256
#include <iostream>
#define dump(x) cout << #x << " = " << (x) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl


using namespace std;

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

    Yes(s[2] == s[3] && s[4] == s[5]);
}


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


int main(void){
	int n;
	int h[1024];
	int ans=1;
	scanf("%d",&n);

	int i;
	for(i=0;i<n;i++){
		scanf("%d",&h[i]);
	}
	int j;

	for(i=1;i<n;i++){
		int flag=1;
		for(j=i-1;j>=0;j--){
			if(h[i]<h[j]){
				flag = 0;
				break;
			}
		}
		if(flag==1){
			ans++;
		}
	}

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


Measured memory_bytes: 128
n = int(input())
s = list(input())

def z_algo(s):
    l = len(s)
    count = [0]*l
    i = 1
    j = 0
    count[0] = l
    while i < l:
        while i+j < l and s[i+j] == s[j]:
            j += 1
        count[i] = j
        if j == 0:
            i += 1
            continue
        
        k = 1
        while l - i > k and k < j-count[k]:
            count[i+k] = count[k]
            k += 1
        i += k
        j -= k
    return count
count = 0
for i in range(n):
    ans = z_algo(s[i:])
    for j in range(n-i):
        count = max(count,min(ans[j],j))

print(count)

Measured memory_bytes: 51036
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  
  int N, i, Ab = 0, Manzoku = 0;
  cin >> N;
  vector<int> A(N), B(N), C(N-1);
  
  for(i = 0; i < N; i++) cin >> A.at(i);
  for(i = 0; i < N; i++) cin >> B.at(i);
  for(i = 0; i < N - 1; i++) cin >> C.at(i);
  
  
  for(i = 0; i < N; i++){
    
    if (i == 0 || A.at(i) - Ab != 1){
      
      Manzoku += B.at(i);
      
    }else {
      
      Manzoku += B.at(i) + C.at(A.at(i) - 2);
      
    }
    Ab = A.at(i);
  }
  cout << Manzoku << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define fast_io() ios::sync_with_stdio(false); cin.tie(nullptr)

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;


int main(void){
    fast_io();
    ll n;
    cin >> n;
    vector<string> s(n);
    rep(i,n){
        cin >> s[i];
    }

    rep(i,n){
        sort(s[i].begin(),s[i].end());
    }

    sort(s.begin(),s.end());
    string temp = "";
    string &current = temp;
    ll count = 0;
    ll ans = 0;
    rep(i,n){
        if(current != s[i]){
            count = 0;
            current = s[i];
        } else {
            count++;
            ans += count;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5196
uses math;
var n:int64;
    ans,i,t:longint;
function tryit(x:int64):longint;
var ans:longint;
    now:int64;
begin
  now:=x;ans:=0;
  while (now<>0) do
  begin
    inc(ans);now:=now div 10;
  end;
  exit(ans);
end;
begin
  readln(n);
  ans:=20;
  for i:=1 to trunc(sqrt(n)) do
    if (n mod i=0) then
    begin
	  t:=max(tryit(i),tryit(n div i));
	  if (t<ans) then ans:=t;
	end;
  writeln(ans);
end.
	  

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = 3077;
const int MAXT = 6077;

ll dp[MAXN][MAXT];
int n, T;
pll a[MAXN];

void relax(ll& x, ll y) {
	x = (x > y ? x : y);
}

void init() {
	for(int i = 0; i < MAXN; ++i) {
		for(int j = 0; j < MAXN; ++j) {
			dp[i][j] = -LL_INF;
		}
	}
}

bool compare(const pll& lhs, const pll& rhs) {
	if(lhs.first != rhs.first) {
		return lhs.first < rhs.first;
	} else {
		return lhs.second > rhs.second;
	}
}

void solve() {
	cin >> n >> T;

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

	sort(a, a + n, compare);
	dp[0][0] = 0;

	for(int i = 0; i < n; ++i) {
		for(int t = 0; t < MAXT; ++t) {
			relax(dp[i + 1][t], dp[i][t]);

			if(t < T) {
				relax(dp[i + 1][t + a[i].first], dp[i][t] + a[i].second);
			}
		}
	}

	ll answ = -LL_INF;

	for(int t = 0; t < MAXT; ++t) {
		relax(answ, dp[n][t]);
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 143616
#!/usr/bin/env python3
import collections

N = int(input().split()[0])
a_list = list(map(int, input().split()))

counter = collections.Counter(a_list)

# 4種類以上だと、どうしようもない
is_ok = True
if len(counter) > 4:
    is_ok = False
elif len(counter) == 3:
    v_list = list(counter.values())
    if len(set(v_list)) != 1:
        # 全部同じ数ではない
        is_ok = False

    if is_ok:
        k_list = list(counter.keys())
        if k_list[0] ^ k_list[1] != k_list[2]:
            is_ok = False
elif len(counter) == 2:
    v_list = list(counter.values())
    if min(v_list) * 2 == max(v_list):
        a = [k for k, v in counter.items() if v == max(v_list)][0]
        b = [k for k, v in counter.items() if v == min(v_list)][0]
        if a ^ a != b:
            is_ok = False
    else:
        is_ok = False
else:
    for k in counter.keys():
        if k != 0:
            is_ok = False
            break

ans = "Yes" if is_ok else "No"

print(ans)


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

using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int k, s;
	cin >> k >> s;
	int ans = 0;
	for(int i=0; i<=k; i++)
		for(int j=0; j<=k; j++)
			if(s-i-j >= 0 && s-i-j <= k)
				ans++;

	cout << ans << endl;

	return 0;
}


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

int main() {
    int a,b,k;
    cin >> a >> b >> k;
    rep2(i,a,b+1) {
        if(i < a+k || b-k < i) cout << i << endl;
    }
}

Measured memory_bytes: 384
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}

const ll N=3e5+5;

ll dp[N][21];

int main()
{ 

IOS;

ll n;cin>>n;

vl a(n+1);

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

for(int i=1;i<=n;i++){
  ll c=a[i];
  for(int j=20;j>=0;j--){
     dp[i][j]=dp[i-1][j];
    if(1ll<<j&c){
      dp[i][j]++;
 //     cout<<1;
    }
   // else cout<<0;
  }
//  cout<<endl;
}

ll cnt=0;

for(int i=1;i<=n;i++){

ll l=i,r=n,mid;
ll temp=i;
while(l<=r){
  mid=(l+r)/2;
  bool allowed=1;
  for(int j=20;j>=0;j--){
if(dp[mid][j]-dp[i-1][j]>1){
  allowed=0;
  break;
  }
}

if(!allowed)r=mid-1;
else {
l=mid+1;
temp=max(temp,mid);
}
}
//cout<<temp<<endl;
cnt+=(temp-i+1);

}

cout<<cnt<<endl;

return 0;
 
}



Measured memory_bytes: 37504
#include <bits/stdc++.h>
using namespace std;
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v){
  const char* dlm = "";
  for(const auto& x:v) os << exchange(dlm, " ") << x;
  return os;
}
struct UnionFind{
  using val_t=size_t;
  vector<val_t> par;
  explicit UnionFind(size_t n): par(n){
    init(n);
  }
  void init(size_t n){
    iota(begin(par), end(par), 0);
  }
  val_t root(val_t s){
    if(par[s]!=s) par[s]=root(par[s]);
    return par[s];
  }
  void unite(val_t s, val_t t){
    par[root(s)]=root(t);
  }
  bool same(val_t s, val_t t){
    return root(s)==root(t);
  }
};
int32_t main(){
  size_t n,m; cin>>n>>m;
  vector<size_t> p(n);
  for(auto&& x:p) {cin>>x; --x;}
  UnionFind tree(n);
  size_t x,y;
  for(size_t i=0; i<m; ++i){
    cin>>x>>y;
    tree.unite(p[x-1],p[y-1]);
  }
  size_t ret=0;
  for(size_t i=0; i<n; ++i){
    if(tree.same(i,p[i])) ++ret;
  }
  cout<<ret<<endl;
  // cout<<tree.par;
}

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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
void solve() {
  int s, w;
  scanf("%d%d", &s, &w);
  if (w >= s) puts("unsafe");
  else puts("safe");
}

int main() {
  // int _; scanf("%d", &_); while (_--)
  // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  // int _; cin >> _; while(_--)
  solve();
	return 0;
}



Measured memory_bytes: 3596
import math

N, H = map(int, input().split())
A = []
B = []
for i in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort(reverse=True)
B.sort(reverse=True)

a_max = A[0]

ans = 0
bi = 0
while H > 0:
    if bi < N and a_max <= B[bi]:
        ans += 1
        H -= B[bi]
        bi += 1
    else:
        ans += math.ceil(H / a_max)
        break
print(ans)


Measured memory_bytes: 16984
#!/usr/bin/env python3
import sys


def solve(N: int, S: "List[str]"):
    s = set()

    for thing in S:
        s.add(thing)

    print(len(s))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 103596
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const MOD: usize = 1000000007;

fn pow(base: usize, exp: usize, m: usize) -> usize {
    if exp == 0 {
        return 1;
    }
    if exp % 2 == 0 {
        let ret = pow(base, exp / 2, m);
        ret * ret % m
    } else {
        base * pow(base, exp - 1, m) % m
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let m: usize = sc.get();
    let n: usize = sc.get();
    println!("{}", pow(m, n, MOD));
}



Measured memory_bytes: 5032
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int arr[n+2];
	long long ans = 0;
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	if(n == 1){
		cout<<"0\n";
		return 0;
	}
	for(int i = 1; i < n; i++){
		ans += max(arr[i-1] - arr[i], 0);
		arr[i] += max(arr[i-1] - arr[i], 0);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    ll n = 0, x = 0, ans = 0;
    cin >> n >> x;
    vector<ll> vec(n);
    rep(i, n) cin >> vec.at(i);
    rep(i, n - 1) {
        if (vec.at(i) + vec.at(i + 1) > x) {
            ans += max((ll)0, abs(x - (vec.at(i) + vec.at(i + 1)))); //キャンディの数を0より小さくしないようにしてる
            vec.at(i + 1) = max((ll)0,vec.at(i + 1) - abs(x - (vec.at(i) + vec.at(i + 1))));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
// AOJ 1308 Awkward Lights
// 2018.3.8 bal4u

//#include <stdio.h>
//#include <string.h>
//#include "bits/stdc++.h"
#include <bits/stdc++.h>
using namespace std;

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int inbit()
{
	int c = getchar_unlocked();
	getchar_unlocked();
	return c & 1;
}

#define N 630

bitset <N> B[N];

int gauss_jordan(int n)
{
	int i, j, pivot;

	for (i = 0; i < n; i++) {
		pivot = -1;
		for (j = i; j < n; j++) if (B[j][i]) { pivot = j; break; }
		if (pivot < 0) continue;

		swap(B[pivot], B[i]);

		for (j = 0; j < n; j++) if (i != j && B[j][i]) B[j] ^= B[i];
	}

	for (i = 0; i < n; i++) if (!B[i][i] && B[i][n]) return 0;
	return 1;
}

#define ABS(a)	((a)>=0?(a):-(a))
#define ID(r,c)	((r)*m+(c))

int main()
{
	int m, n, mn, d, i, j, r, c;

	while (m = in()) {
		n = in(), d = in(), mn = m*n;
		memset(B, 0, sizeof(B));

		for (i = 0; i < n; i++) for (j = 0; j < m; j++) {
			if (inbit()) B[ID(i,j)][mn] = 1;
			for (r = 0; r < n; r++) for (c = 0; c < m; c++) {
				if (r == i && c == j || ABS(r-i)+ABS(c-j) == d)
					B[ID(i,j)][ID(r,c)] = 1;
			}
		}
		putchar('0' + gauss_jordan(mn)), putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N,M;cin>>N>>M;
  vector<ll> h(N);
  rep(i,N) cin>>h[i];
  vector<P> a(M);
  rep(i,M){
    ll c,d;cin>>c>>d;
    c--; d--;
    a[i].first = c; a[i].second = d;
  }

  map<ll,ll> m;

  rep(i,M){
    if(h[a[i].first] < h[a[i].second]){
      m[a[i].first]++;
    }
    else if(h[a[i].first] == h[a[i].second]){
      m[a[i].first]++;
      m[a[i].second]++;
    }
    else{
      m[a[i].second]++;
    }
  }
  ll ans = 0;
  rep(i,N){
    if(m[i] == 0) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 11968