akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin >>n >>m;
    int s[6],c[6];
    for(int i=0;i<m;i++) 
        cin >>s[i] >>c[i];
    for(int i=0;i<=999;i++)
    {
        string str = to_string(i);
        if(str.size()==n)
        {
            int cnt = 0;
            for(int j=0;j<m;j++)
            {
                if(str[s[j]-1]!=c[j]+'0') 
                    break;
                else cnt++;
            }
            if(cnt==m)
            {
                cout << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

int main(){
	ll a,b ;
	cin >> a >> b ;
	b++ ;
	ll ans = 0 ;
	ll two = 1 ;
	for(int i=0;i<50;i++){
//		cout << ans << " " ;
		two *= 2 ;
		ll cnt = b/two*two/2+min(b%two,two/2) ;
//		cout << cnt << " " ;
		cnt -= a/two*two/2+min(a%two,two/2) ;
//		cout << cnt << endl ;
		if((b-a-cnt)&1) ans += two/2 ;
	}
	cout << ans << endl ;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,int> P;

int main() {
    int A,B;
    cin >> A >> B;
    if(abs(A - B) <= 1) {
        cout << "Yay!" << endl;
    }
    else {
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.lang.Math;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        long k = sc.nextLong();
        long[][] ab = new long[n][2];
        for (int i = 0; i < n; i++) {
            long a = sc.nextLong();
            long b = sc.nextLong();
            long[] tmp = {a,b};
            ab[i] = tmp;
        }
        Arrays.sort(ab, (a, b) -> Long.compare(a[0], b[0]));
        long sum = 0;
        long ans = 0;
        for (int i = 0; i < n; i++) {
            sum += ab[i][1];
            if (sum >= k) {
                ans = ab[i][0];
                break;
            }
        }
        System.out.println(ans);
    }

}


Measured memory_bytes: 96580
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
using namespace std;
typedef	long long int ll;

int main(){
    int n;
    cin >> n;
    int a[n+1];
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    a[0] = 0;
    int sum = 0;
    int b[n+1];
    for(int i = 0; i <= n; i++){
        if(i == n) b[i] = abs(a[i]);
        else b[i] = abs(a[i]-a[i+1]);
        sum += b[i];
    }
    for(int i = 1; i <= n; i++){
        if(i == n) cout << sum - b[i-1] - b[i] + abs(a[i-1]) << endl;
        else cout << sum - b[i-1] - b[i] + abs(a[i+1]-a[i-1]) << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
#include <cmath>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <iomanip>

using namespace std;

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

const ll  MOD = 1e9 + 7;
int main()
{
    int N; cin >> N;
    vector<int> T[2];
    rep(i, 2) T[i].resize(N);
    rep(i, 2) rep(j, N) cin >> T[i][j];
    reverse(T[1].begin(), T[1].end());

    vector<int> mx[2], mn[2];
    rep(i, 2) {
        mx[i].resize(N);
        mn[i].resize(N);
    }

    rep(j, 2) {
        mx[j][0] = mn[j][0] = T[j][0];
        REP(i, 1, N) {
            if (T[j][i] > T[j][i-1]) {
                mx[j][i] = mn[j][i] = T[j][i];
            } else {
                mn[j][i] = 1;
                mx[j][i] = T[j][i];
            }
        }
    }

    reverse(mn[1].begin(), mn[1].end());
    reverse(mx[1].begin(), mx[1].end());

    ll ans = 1LL;
    rep(i, N) {
        ll tmpmn = max(mn[0][i], mn[1][i]);
        ll tmpmx = min(mx[0][i], mx[1][i]);

        ans *= max(0LL, (tmpmx - tmpmn + 1));
        ans %= MOD;
    }
    cout << ans << endl;
}



Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=100000+10;
int a[maxn],dis[maxn],co[maxn],h[maxn],go[maxn],nxt[maxn],cnt[maxn];
bool bz[maxn],pd[maxn];
int i,j,k,l,t,n,m,tot,top,ans,mi;
void add(int x,int y){
	go[++tot]=y;
	nxt[tot]=h[x];
	h[x]=tot;
}
void travel(int x){
	int t=h[x];
	while (t){
		if (!bz[go[t]]){
			bz[go[t]]=1;
			co[go[t]]=(co[x]+1)%k;
			cnt[(k-co[go[t]])%k]++;
			travel(go[t]);
		}
		t=nxt[t];
	}
}
void dfs(int x){
	dis[x]=1;
	int t=h[x];
	while (t){
		dfs(go[t]);
		dis[x]=max(dis[x],dis[go[t]]+1);
		t=nxt[t];
	}
	if (dis[x]>=k&&a[x]>1){
		ans++;
		dis[x]=0;
	}
}
int main(){
	scanf("%d%d",&n,&k);
	//k++;
	fo(i,1,n) scanf("%d",&a[i]);
	if (a[1]!=1){
		ans++;
		a[1]=1;
	}
	fo(i,2,n) add(a[i],i);
	/*fo(i,1,n)
		if (!bz[i]){
			j=i;
			while (1){
				pd[j]=1;
				j=a[j];
				if (pd[j]) break;
			}
			t=top=0;
			while (1){
				top++;
				co[j]=t;
				if (j>1) cnt[co[j]]++;
				t=(t+1)%k;
				bz[j]=1;
				j=a[j];
				if (bz[j]) break;
			}
			l=j;
			while (1){
				travel(j);
				j=a[j];
				if (j==l) break;
			}
			mi=n+1;
			fo(j,0,min(top-1,k-1)) mi=min(mi,cnt[j]);
			fo(j,0,min(top-1,k-1)) cnt[j]=0;
			ans+=mi;
		}*/
	dfs(1);
	printf("%d\n",ans);
}

Measured memory_bytes: 5248
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#define MAX 1000000
using namespace std;
int prime[1000009];
void sive()
{
    int i,j,k,c=0;
    prime[0]=1;
    prime[1]=1;
    for(i=2;i*i<=1000009;i++)
    {
        if(prime[i]==0)
        {
            for(j=i+i;j<1000009;j+=i)
            {
                prime[j]=1;
            }
        }
    }
}
int main()
{
    int st,en,i,c=0,co;
    int b[100];
    sive();
     //printf("1");

    while(scanf("%d",&en)==1)
    {
        co=0;
    for(i=2;i<=en;i++)
    {
        if(prime[i]==0)
        //printf("1");
        {
            co++;
        }
    }
            printf("%d\n",co);
    }

    return 0;
}

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

bool chk[100010];
int cnt[100010];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);

    int p = 0;
    int q = 0;
    for(int i = 0; i < m; i++)
    {
        int x;
        char c;
        scanf("%d %c%*c", &x, &c);

        if(c == 'A')
        {
            if(!chk[x])
            {
                chk[x] = 1;
                p++;
                q += cnt[x];
            }
        }
        else
        {
            cnt[x]++;
        }
    }

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


Measured memory_bytes: 768
def calc_pws(str)
  arr = str.split(' ')
  stack = []
  arr.each do |cw|
    if cw =~ /[1-9]+/
      stack.push(cw.to_f)
    else
      b, a = stack.pop, stack.pop
      stack <<
        case cw
          when '+' then a+b
          when '-' then a-b
          when '*' then a*b
          when '/' then a/b
        end
    end
  end
  return stack.pop
end

while gets do
  str = $_
  puts sprintf('%.6f', calc_pws(str))
end

Measured memory_bytes: 6148
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<pair<ll, ll>>> net(n);
    for(int i = 0; i < m; ++i){
        ll l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        net.at(l).push_back(make_pair(r, d));
        net.at(r).push_back(make_pair(l, -d));
    }

    vector<bool> touched(n, false);
    vector<ll> pos(n);
    for(int i = 0; i < n; ++i){
        if(touched.at(i)){ continue; }
        queue<ll> q;
        touched.at(i) = true;
        q.push(i);
        while(!q.empty()){
            ll p = q.front();
            q.pop();
            for(auto n : net.at(p)){
                if(touched.at(n.first)){
                    if(pos.at(n.first) != pos.at(p) + n.second){
                        cout << "No" << endl;
                        return 0;
                    }
                }else{
                    pos.at(n.first) = pos.at(p) + n.second;
                    touched.at(n.first) = true;
                    q.push(n.first);
                }
            }
        }
    }

    const ll maxpos = *max_element(pos.begin(), pos.end());
    const ll minpos = *min_element(pos.begin(), pos.end());
    if(maxpos - minpos > 1000000000LL){
        cout << "No" << endl;
        return 0;
    }

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


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

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

int main() {
  i64 l, r;
  cin >> l >> r;
  if (r - l + 1 >= 2019) { cout << 0 << endl; return 0; }
  i64 lm = l % 2019, rm = r % 2019;
  bool b = lm <= rm;
  i64 ans = 2019;
  for (i64 i = l; i <= r; ++i) {
    for (i64 j = i + 1; j <= r; ++j) {
      ans = min(ans, i * j % 2019);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 3e3 + 10 , M = 2e5 + 10;
int pre[N] , cnt[N] , ans;
string s; 
signed main()
{
	cin >> s ;
	for(auto i : s)
	{
		int x = i - '0';
		memset(cnt , 0 , sizeof(cnt));
		for(int j = 0 ; j <= 2018 ; j ++)
		{
			int nd = (j * 10 + x) % 2019;
			if(!nd) ans += pre[j];
			cnt[nd] += pre[j];
		}
		cnt[x] ++ ;
		for(int j = 0 ; j <= 2018 ; j ++) pre[j] = cnt[j]; 
	}
	cout << ans << '\n'; 
	return 0;
}

Measured memory_bytes: 3728
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


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

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] * 4 * m >= sum)ans++;
	}

	if (ans >= m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <sstream>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

struct dfs
{
    int i;
    vector<int> &ts;
    vector<int> &tsinv;
    vector<vector<int>> const &adjs;
    void f(int s)
    {
        if (tsinv[s] >= 0)
        {
            return;
        }

        for (auto t : adjs[s])
        {
            f(t);
        }

        ts[i] = s;
        tsinv[s] = i;
        ++i;
        return;
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n, m;
    cin >> n >> m;
    vector adjs(n, vector<int>());
    rep(i, m)
    {
        int s, t;
        cin >> s >> t;
        --s;
        --t;
        adjs[s].push_back(t);
    }

    vector<int> ts(n, -1), tsinv(n, -1);
    {
        dfs func = {0, ts, tsinv, adjs};
        rep(s, n)
        {
            func.f(s);
        }
    }

    vector dp(n, 0);
    int ans = -1;
    rep(i, n)
    {
        int s = ts[i];
        for (auto t : adjs[s])
        {
            int j = tsinv[t];
            chmax(dp[i], dp[j] + 1);
        }

        chmax(ans, dp[i]);
    }

    cout << ans << '\n';

    return 0;
}


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

long DP[120][10];
long h[120], f[120], g[120];

int main() {
    long mod = 1e9+7;
    int H, W, K;
    cin>>H>>W>>K;
    H++;
    DP[0][0] = 1;
    f[1] = 1;
    g[1] = 1;
    h[0] = 1;
    h[1] = 2;

    for(int i=2;i<=W;++i){
        f[i] = g[i-1];
        g[i] = f[i-1] + g[i-1];
        h[i] = f[i] + g[i];
    }
    if(W==1){
        cout<<1<<endl;
    }
    else{
    for(int i=1;i<H;++i){
        for(int j=0;j<W;++j){
            if(j==0){
                DP[i][j] = DP[i-1][j] * h[max(0, W-2)] + DP[i-1][j+1] * h[max(0, W-3)];
                DP[i][j] %= mod;
            }
            else if(j==W-1){
                DP[i][j] = DP[i-1][j] * h[max(0, W-2)] + DP[i-1][j-1] * h[max(0, W-3)];
                DP[i][j] %= mod;
            }
            else{
                DP[i][j] = (DP[i-1][j] * h[max(0, j-1)] * h[max(0, W-j-2)])%mod + (DP[i-1][j-1] * h[max(0, j-2)] * h[max(0, W-j-2)])%mod + (DP[i-1][j+1] * h[max(0, j-1)] * h[max(0, W-j-3)])%mod;
                DP[i][j] %= mod;
            }
        }
    }
    cout<<DP[H-1][K-1]<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int N = 5005;
const int mod = 1e9 + 7;
using namespace std;

vector <int> adj[N];
int n, dp[N][N][2], num[N], cur[N][2];
int f[N], ans;

void add(int&a, int b){
    a += b; if (a >= mod) a -= mod; if (a < 0) a += mod;
}

int po(int n, int k){
    int ans = 1;
    while (k){
        if (k&1) ans = 1LL * ans * n % mod;
        n = 1LL * n * n % mod;
        k >>= 1;
    }
    return ans;
}

void dfs(int u, int p){
    num[u] = 1;
    dp[u][1][0] = 1;
    for (auto v : adj[u]){
        if (v == p) continue;
        dfs(v, u);
        for (int i = 0; i <= num[u]+num[v]; i++) cur[i][0] = cur[i][1] = 0;
        for (int i = 1; i <= num[u]; i++){
            for (int j = 0; j <= num[v]; j++){
                add(cur[i+j][0], 1LL * dp[u][i][0] * dp[v][j][0] % mod);
                add(cur[i+j][0], 1LL * dp[u][i][1] * dp[v][j][1] % mod);
                add(cur[i+j][1], 1LL * dp[u][i][0] * dp[v][j][1] % mod);
                add(cur[i+j][1], 1LL * dp[u][i][1] * dp[v][j][0] % mod);
            }
        }
        num[u] += num[v];
        for (int i = 1; i <= num[u]; i++){
            dp[u][i][0] = cur[i][0]; dp[u][i][1] = cur[i][1];
        }
    }
    for (int i = 1; i <= num[u]; i ++) {
        add(dp[u][0][0], 1LL * dp[u][i][1] * f[i] % mod);
        add(dp[u][0][1], 1LL * dp[u][i][0] * f[i] % mod);
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    f[0] = 1;
    for (int i = 2; i < N; i += 2) f[i] = 1LL * f[i-2] * (i-1) * i % mod * po(i, mod-2) % mod;
    cin >> n;
    for (int i = 2; i <= n; i++){
        int x, y;
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(1, 1);
    ans = dp[1][0][1] - dp[1][0][0]; if (ans < 0) ans += mod;
    cout << ans << endl;
}


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

using namespace std;

using ll = long long int;

ll ara[50][50],mod=1e9+7,dp[22][(1LL<<22)+5],n;

ll Set(ll N, ll pos)
{
    return N = (N | (1LL<<pos));
}

bool Check(ll N, ll pos)
{
    return (bool)(N & (1LL<<pos));
}

ll func(ll indx, ll mask)
{
    if(mask==(1LL<<n)-1 || indx==n+1) return 1;
    if(dp[indx][mask]!=-1) return dp[indx][mask];
    ll ans=0;
    for(ll i=1; i<=n; i++)
    {
        if(ara[indx][i]==1 && !Check(mask,i))
        {
            ans+=func(indx+1,Set(mask,i));
            ans%=mod;
        }
    }

    return dp[indx][mask]=ans;
}

int main()
{
    ll i,j;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=n; j++)
        {
            cin>>ara[i][j];
        }
    }

    memset(dp, -1, sizeof dp);
    ll ans=func(1,0);
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 721280
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};

int d(P a, P b) {
    return abs(a.first-b.first)+abs(a.second-b.second);
}

int main(){
  int n;
  cin >> n;
  int x = 800*n;
  int y = (n/15)*200;
  cout << x-y << endl;
  return 0;
}

Measured memory_bytes: 3576
#!/usr/bin/env python3
from itertools import product
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, A: int, B: int, C: int, l: "List[int]"):
    m = None
    for p in product(range(4), repeat=N):
        a = {i for i in range(N) if p[i] == 0}
        b = {i for i in range(N) if p[i] == 1}
        c = {i for i in range(N) if p[i] == 2}
        if not a or not b or not c:
            continue
        md = (
            abs(sum(l[ai] for ai in a) - A) + 10 * (len(a) - 1) +
            abs(sum(l[bi] for bi in b) - B) + 10 * (len(b) - 1) +
            abs(sum(l[ci] for ci in c) - C) + 10 * (len(c) - 1)
        )
        if m is None or m > md:
            m = md

    print(m)


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
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    l = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A, B, C, l)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define INF 1000000000000000000
typedef long long ll;
int main(){
    vector<bool>p(100020,true);
    p[0]=p[1]=false;
    for(int i=2;i*i<100020;i++){
        if(p[i]==1){
            for(int j=2;i*j<100020;j++)p[i*j]=false;
        }
    }
    vector<int>Count(100020);
    Count[0]=Count[1]=Count[2]=0;
    int co=0;
    for(int i=3;i<100020;i++){
        if(p[i]&&p[i/2+1])co++;
        Count[i]=co;
    }
    int q;cin>>q;
    int l,m;
    rep(i,q){
        cin>>l>>m;
        cout<<Count[m]-Count[l-1]<<endl;
    }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char a, b, c;
	cin >> a >> b >> c;
	if (a != 'R' and b != 'R' and c != 'R')
		cout << 0;
	else if (a == 'R' and b == 'R' and c == 'R')
		cout << 3;
	else if ((a == 'R' and b == 'R') or (b == 'R' and c == 'R'))
	{
		cout << 2;
	}
	else
		cout << 1;
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#define pii pair<int,int>
#define S second
#define F first

using namespace std;
const int MAX_N = 1e5+10;
const int INF = 1e9+10;
int from[MAX_N],to[MAX_N],DP[MAX_N],depth[MAX_N];
vector <int> vec[MAX_N];
vector <pii> ans;
bool mark[MAX_N];
void dfs(int v,int cnt,int l){
    mark[v]=true;
    depth[v]=cnt;
    for(int en:vec[v]){
        if(en==l)
            continue;
        int u=to[en]^from[en]^v;
        if(mark[u])
            DP[v]=min(DP[v],depth[u]);
        else{
            dfs(u,cnt+1,en);
            DP[v]=min(DP[v],DP[u]);
        }
    }
    if(DP[v]>=depth[v]&&l!=-1)
        ans.push_back({from[l],to[l]});
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin>>n>>m;
    if(n==1)
        return 0;
    fill(DP,DP+max(n,m),INF);
    for(int i=0;i<m;i++){
        cin>>from[i]>>to[i];
        if(from[i]>to[i])
            swap(from[i],to[i]);
        vec[from[i]].push_back(i);
        vec[to[i]].push_back(i);
    }
    dfs(0,0,-1);
    sort(ans.begin(),ans.end());
    for(pii u:ans)
        cout<<u.F<<" "<<u.S<<'\n';

}

Measured memory_bytes: 7572
#include <stdio.h>

int main(){
    
    int i,j,H,W;
    
    while(1){
        
        scanf("%d %d", &H, &W);
        
        if( H == 0 && W == 0){
            break;
        }
        
        else{
            for( i = 1; i <= H; i++){
                if( i%2 == 1 ){
                    for( j = 1; j <= W;j++){
                        if( j%2 == 1 ){
                            printf("#");
                        }
                        
                        else{
                            printf(".");
                        }
                    }
                }   
                
                else{
                    for( j = 1; j <= W;j++){
                        if( j%2 == 1 ){
                            printf(".");
                        }
                        
                        else{
                            printf("#");
                        }
                    }
                }
                    
            printf("\n");
            }        
         printf("\n");
        }
    }
    return 0;
}               

Measured memory_bytes: 572
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;


int main(){
   string S;
   cin >> S;
   string b="2019/04/30";
   for(int i=0;i<b.size(); i++){
      if(S[i]>b[i]){
         cout <<"TBD"<<endl;
         return 0;
      }
      if(S[i]<b[i]){
         cout <<"Heisei"<<endl;
         return 0;
      }
   }
   cout << "Heisei"<<endl;
   return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
using ull = unsigned long long;
using P = pair<int, int>;

static constexpr ull MOD = 1000000007;
static constexpr double pi = 3.14159265359;

int main() {
    int N;
    cin >> N;
    double ans = 0;
    for (int i = 0; i < N; ++i) {
        double x;
        string u;
        cin >> x;
        cin >> u;
        if (u == "JPY") {
            ans += x;
        } else {
            ans += 380000.0 * x;
        }
    }
    printf("%lf\n", ans);
}


Measured memory_bytes: 256
class Unionfind:
     
    def __init__(self,n):
        self.uf = [-1]*n
 
    def find(self,x):
        if self.uf[x] < 0:
            return x
        else:
            self.uf[x] = self.find(self.uf[x])
            return self.uf[x]
 
    def same(self,x,y):
        return self.find(x) == self.find(y)
 
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.uf[x] > self.uf[y]:
            x,y = y,x
        self.uf[x] += self.uf[y]
        self.uf[y] = x
        return True
 
    def size(self,x):
        x = self.find(x)
        return -self.uf[x]

n,m = map(int,input().split())
s = [[] for i in range(m+1)]
u = Unionfind(n)
for i in range(n):
    l = list(map(int,input().split()))
    for j in l[1:]:
        if s[j]:
            u.union(i,s[j][0])
        else:
            s[j].append(i)
if u.size(0) == n:
    print("YES")
else:
    print("NO")

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

int main() {
	int arr[3];
	int a, b, c;
	scanf("%d %d %d", &arr[0], &arr[1], &arr[2]);
	sort(arr, arr+3);
	int ans=(arr[2]*10)+arr[1]+arr[0];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 6e5;
const int mod = 1e9+7;
int n,m,inv[600100],p[600100];
inline int pw(int x,int p){
	int res=1;
	while(p){
	  if(p&1)res=res*x%mod;
	  x=x*x%mod;
	  p>>=1;
	}
	return res;
}
inline int c(int nn,int mm){
	if(nn<mm)return 0;
	return p[nn]*inv[mm]%mod*inv[nn-mm]%mod;
}
inline int work(int r){
	int i,j,k,res=0;
	for(k=1;k<=r;k++){
	  for(i=0;i<=m;i++){
	  	if(r-(n-m+i)*k<0)break;
	  	if(i&1)res=(res+c(m,i)*c(r-(n-m+i)*k+n,n)%mod)%mod;
	  	  else res=(res-c(m,i)*c(r-(n-m+i)*k+n,n)%mod+mod)%mod;
	  }
	  for(i=0;i<=m;i++){
	  	if(r-(n-m)*(k+1)-k*i<0)break;
	  	if(i&1)res=(res-c(m,i)*c(r-(n-m)*(k+1)-k*i+n,n)%mod+mod)%mod;
	  	  else res=(res+c(m,i)*c(r-(n-m)*(k+1)-k*i+n,n)%mod)%mod;
	  }
	}
	res=res*c(n,m)%mod;
	res=(res+c(n+r,n))%mod;
	return res;
}
signed main(){
	int i,j,k,l,r;
	scanf("%lld%lld%lld%lld",&n,&m,&l,&r);
	m=n-m;
	p[0]=1;
	for(i=1;i<=N;i++)p[i]=p[i-1]*i%mod;
	inv[N]=pw(p[N],mod-2);
	for(i=N-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
	printf("%lld\n",(work(r)-work(l-1)+mod)%mod);
	return 0;
}

Measured memory_bytes: 9728
#include <stdio.h>
#define MOD 1000000007
#define ll long long
ll a[100000];
ll b[100000];
int main(void){
    ll n,m;
    ll p=0,q=0;
    scanf("%lld %lld",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    for(int i=0;i<m;i++){
        scanf("%lld",&b[i]);
    }
    for(int i=1;i<n;i++){
        p += i*(n-i)*(a[i]-a[i-1]);
        p %= MOD;
    }
    for(int i=1;i<m;i++){
        q += i*(m-i)*(b[i]-b[i-1]);
        q %= MOD;
    }
    printf("%lld\n",p*q%MOD);
    return 0;
}




Measured memory_bytes: 1664
n = int(input())
y0 = int(input())
y1 = int(input())
m = min(y0, y1)
M = y1 - y0
i = 2
while i < n:
    y = int(input())
    M = max(M, y - m)
    m = min(m, y)
    i += 1
print(M)


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
const ll inf=1e18;

int main() {
  ll n;
  cin >> n;
  map<ll,ll> d;
  for(ll i=0;i<n;i++) {
    ll temp;
    cin >> temp;
    d[temp]++;
  }
  ll m;
  cin >> m;
  for(ll i=0;i<m;i++) {
    ll temp;
    cin >> temp;
    if(d[temp]>0) {
      d[temp]--;
    }
    else {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
long long n,W;
void solve()
{
    vector < long long > w(n+1),v(n+1);
    long long i,j,a[n+1][W+1];
    for (i=1;i<=n;i++)
        cin>>w[i]>>v[i];
    for (i=0;i<=n;i++)
        for (j=0;j<=W;j++)
            a[i][j]=0;
    for (i=1;i<=n;i++)
        for (j=1;j<=W;j++)
            if (j<w[i]) a[i][j]=a[i-1][j];
            else
            {
                if (a[i-1][j]>a[i-1][j-w[i]]+v[i]) a[i][j]=a[i-1][j];
                else a[i][j]=a[i-1][j-w[i]]+v[i];
            }
    cout<<a[n][W]<<endl;
}
int main()
{
    while(cin>>n>>W)
        solve();
}

Measured memory_bytes: 79104
#!/usr/bin/env python3

def main():
    x1, y1, x2, y2 = map(int, input().split())
    d12 = [x2 - x1, y2 - y1]
    d23 = turn_90_degs(d12)
    d34 = turn_90_degs(d23)
    x3 = x2 + d23[0]
    y3 = y2 + d23[1]
    x4 = x3 + d34[0]
    y4 = y3 + d34[1]
    print(x3, y3, x4, y4)

def turn_90_degs(v):
    u = [-v[1], v[0]]
    return u

main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

char a[2][510][510];
char s[510];

int main()
{
	int n, m;
	read(n, m);
	for(int i=1; i<=n; ++i){
		for(int j=1; j<=m; ++j){
			bool c = (i%2==1 && j<m) || (j==1);
			a[c][i][j]='.';
			a[1-c][i][j]='#';
		}
		scanf("%s", s);
		for(int j=1; j<=m; ++j){
			if(s[j-1] == '#') a[0][i][j]=a[1][i][j]='#';
		}
	}
	for(int i=1; i<=n; ++i) puts(a[0][i]+1);
	putchar(10);
	for(int i=1; i<=n; ++i) puts(a[1][i]+1);
	return 0;
}


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

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int N, Q;
    cin >> N >> Q;
    string s;
    cin >> s;
    vector<char> t(Q), d(Q);
    for (int i = 0; i < Q; ++i) {
        cin >> t[i] >> d[i];
    }

    int low = 1, high = N, ans1 = 0;
    while (low <= high) {
        int mid = (low + high) / 2;
        int i = mid - 1;
        for (int j = 0; i >= 0 && i < N && j < Q; ++j) {
            if (t[j] == s[i]) {
                i += (d[j] == 'L' ? -1 : 1);
            }
        }
        if (i < 0) {
            ans1 = mid;
            low = mid + 1;
        } else {
            high = mid - 1;
        }
    }
    
    low = 1, high = N;
    int ans2 = 0;
    while (low <= high) {
        int mid = (low + high) / 2;
        int i = N - mid;
        for (int j = 0; i >= 0 && i < N && j < Q; ++j) {
            if (t[j] == s[i]) {
                i += (d[j] == 'L' ? -1 : 1);
            }
        }
        if (i >= N) {
            ans2 = mid;
            low = mid + 1;
        } else {
            high = mid - 1;
        }
    }

    cout << N - (ans1 + ans2) << "\n";


    return 0;
}

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

int main(){
  double A,B;
  cin >> A >> B;
  int K=(A+B)/2;
  double C=(A+B)/2;
  if(K==C)
    cout << K << endl;
  else
    cout << "IMPOSSIBLE" << endl;
  
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

ll N;
vector<vector<ll>> G(100010);
vector<ll> memo(100010);
map<Pll,ll> mp;
ll K = 1; 

ll dfs(ll v, ll c){
    ll cc = 1;
    for(auto& u:G[v]){
        if(memo[u] != 0) continue;
        memo[u] = 1;
        if(cc == c) cc++;
        cmax(K,cc);
        mp[Pll(v,u)] = cc;
        mp[Pll(u,v)] = cc;
        dfs(u,cc);
        cc++;
    }
    return 0;
}

int main(){
    cin >> N;
    ll a,b;
    vector<Pll> v;
    rep(i,N-1){
        cin >> a >> b;
        a--;b--;
        v.push_back(Pll(a,b));
        G[a].push_back(b);
        G[b].push_back(a);
    }
    memo[0] = 1;
    dfs(0,0);
    cout << K << endl;
    rep(i,N-1){
        cout << mp[v[i]] << endl;
    }
}

Measured memory_bytes: 24464
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
const int MAXN=100005;
const ll INF=1000000000000000;
int n,m,s,t;
queue<int>T;
struct node{
	int go,vis;ll dist[5];
	vector<ll>T[5],P;
}w[MAXN];
ll ans[MAXN];
void Add(int a,int b,int c,int d){
	w[a].T[1].push_back(c);
	w[a].T[2].push_back(d);
	w[a].P.push_back(b);
}
void SPFA(int x,int y){
	while(!T.empty())T.pop();
	for(int i=0;i<=n+1;i++)
		w[i].vis=0,w[i].dist[y]=INF;
	T.push(x);w[x].dist[y]=0;
	while(!T.empty()){
		int u=T.front();T.pop();
		w[u].vis=0;
		for(int i=0;i<w[u].P.size();i++){
			int v=w[u].P[i],e=w[u].T[y][i];
			if(e+w[u].dist[y]<w[v].dist[y]){
				w[v].dist[y]=e+w[u].dist[y];
				if(!w[v].vis){
					w[v].vis=1;
					T.push(v);
				}
			}
		}
	}
}
int main(){
	scanf("%d%d%d%d",&n,&m,&s,&t);
	for(int i=1;i<=m;i++){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		Add(a,b,c,d);Add(b,a,c,d);
	}
	SPFA(s,1);SPFA(t,2);
	ans[n+1]=INF;
	for(int i=n;i>=1;i--)
		ans[i]=min(ans[i+1],w[i].dist[1]+w[i].dist[2]);
	for(int i=1;i<=n;i++)
		printf("%lld\n",INF-ans[i]);
}

Measured memory_bytes: 32384
#include <iostream>
#include <algorithm>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	ll a, b, n, ans;

	scanf("%lld%lld%lld", &a, &b, &n);

	if (n < b) {
		ans = a * n / b - a * (n / b);
	}
	else {
		ans = a * (b - 1) / b - a * ((b - 1) / b);
	}

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 3836
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void doIt() {
		int n = sc.nextInt();
		String s[] = new String[n];
		int acnt = 0, bcnt = 0, same = 0;
		for(int i = 0; i < n; i++) {
			s[i] = sc.next();
			char cs = s[i].charAt(0), ce = s[i].charAt(s[i].length() - 1);
			if(cs == 'B' && ce == 'A') {
				acnt++;
				bcnt++;
				same++;
			}
			else if(cs == 'B')acnt++;
			else if(ce == 'A')bcnt++;
		}
		int mcnt = (acnt < bcnt) ? acnt : bcnt;
		if(acnt == bcnt && mcnt == same && same != 0) mcnt--;
		int cnt = 0;
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < s[i].length() - 1; j++) {
				if(s[i].substring(j, j + 2).equals("AB")) {
					cnt++;
				}
			}
		}
		System.out.println(mcnt + cnt);
	}


	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 32544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main{
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        final String[] in = br.readLine().split(" ");
        final int[] s = new int[n];
        for(int i = 0; i<n; i++){
            s[i] = Integer.parseInt(in[i]);
        }
        int c = 0;
        br.readLine();
        final String[] t = br.readLine().split(" ");
        for(final String ti:t){
            if(Arrays.binarySearch(s, Integer.parseInt(ti))>=0) c++;
        }
        System.out.println(c);
    }
}

Measured memory_bytes: 46880
#include <iostream>
using namespace std;
int main()
{
    int n;
    cin >> n;
    while (n > 1)
    {
        if (n % 10 == 7)
        {
            cout << "Yes";
            return 0;
        }
        n = n / 10;
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 3632
#![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()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let mut ans = 0;
    for a in 1..=N {
        for b in (1..).take_while(|i| a * i <= N - 1) {
            if N - a * b >= 1 {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2168
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
typedef unsigned long long ul;
int n;

vector<P> v;
int m[2][600][600];
vector<int> G[360000];
void make_graph(int d) {
	v.clear();
	int k = sqrt(d);
	for (int i = -k-1; i <= k + 1;i++) {
		int r = d - i * i;
		if (r < 0)continue;
		int rk = sqrt(r + 0.1);
		if (rk*rk == r) {
			v.push_back({ i,rk });
			v.push_back({ i,-rk });
		}
	}
	rep(i, n*n) {
		G[i].clear();
	}
	rep(i, n) {
		rep(j, n) {
			rep(l, v.size()) {
				int nx = v[l].first + i; int ny = v[l].second + j;
				if (nx < 0 || ny < 0 || nx >= n || ny >= n)continue;
				int to = nx * n + ny; int cur = i * n + j;
				G[cur].push_back(to);
			}
		}
	}

}
bool used[600][600];
void dfs(int id) {
	rep(i, n) {
		rep(j, n) {
			used[i][j] = false;
		}
	}
	queue<int> q;
	rep(i, n) {
		rep(j, n) {
			if (used[i][j])continue;
			m[id][i][j] = 0;
			q.push(i*n+j); used[i][j] = true;
			while (!q.empty()) {
				int cur = q.front(); q.pop();
				rep(k, G[cur].size()) {
					int to = G[cur][k];
					int nx = to / n, ny = to % n;
					if (used[nx][ny])continue;
					used[nx][ny] = true; q.push(to);
					m[id][nx][ny] = m[id][cur / n][cur%n] ^ 1;
				}
			}
		}
	}
}
vector<P> ans;
int cnt(int i, int j) {
	ans.clear();
	rep(k, n) {
		rep(l, n) {
			if (m[0][k][l] == i && m[1][k][l] == j)ans.push_back({ k,l });
		}
	}
	//cout << ans.size() << endl;
	return ans.size();
}
int main() {
	int d1, d2; cin >> n >> d1 >> d2; n *= 2;
	make_graph(d1); dfs(0);
	make_graph(d2); dfs(1);
	rep(i, 2) {
		rep(j, 2) {
			if (cnt(i, j) >= (n/2)*(n/2)) {
				rep(k, (n/2)*(n/2)) {
					cout << ans[k].first << " " << ans[k].second << endl;
				}
				//stop
				return 0;
			}
		}
	}
	//stop
	return 0;
}


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

int main(){
	static const long double pi = 3.141592653589793;
	int A, B, H, M;
	cin >> A >> B >> H >> M;

	long double Minutes = 60.0*H + M;
	long double thetaA = Minutes/(12*60.0); // ratio
	long double thetaB = M/60.0; // ratio

	long double theta = fmod(thetaA-thetaB, 1.0); //ratio
	long double a = double(A);
	long double b = double(B);


	cout << fixed << setprecision(20) << sqrt(a*a + b*b - 2*a*b*cos(theta*2*pi)) << endl;

	return 0;
}

Measured memory_bytes: 4100
s = input()
t = input()
alp =list("abcdefghijklmnopqrstuvwxyz")
sl = [0] * 26
tl = [0] * 26
for j in range(26):
        sl[j] = s.count(alp[j])
for j in range(26):
        tl[j] = t.count(alp[j])
sl.sort()
tl.sort()
if(sl == tl):
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 64328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N; cin >> N;
    if (N >= 30) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3592
#include<stdio.h>

int main(){
	int w,h,n;
	scanf("%d %d %d",&w,&h,&n);
	int x[n],y[n],a[n];
	int wn[2]={0,w};
	int hn[2]={0,h};
	for(int i=0; i<n; i++) scanf("%d %d %d",&x[i],&y[i],&a[i]);
	for(int i=0; i<n; i++){
		switch(a[i]){
		case 1:
			if(wn[0]<x[i])wn[0]=x[i];
			break;
		case 2:
			if(wn[1]>x[i])wn[1]=x[i];
			break;
		case 3:
			if(hn[0]<y[i])hn[0]=y[i];
			break;
		case 4:
			if(hn[1]>y[i])hn[1]=y[i];
			break;
		}
	}
	if(wn[1]>=wn[0]&&hn[1]>hn[0])printf("%d\n",(wn[1]-wn[0])*(hn[1]-hn[0]));
	else printf("0\n");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
long long ans;
string S;
void solve() {
    cin >> S;
    if (S.length() == 1) {
        cout << 0 << endl;
        return;
    }
    if (S[0] == '0') {
        for (int i = 1; i < S.length(); i++) {
            if (S[i] == '1' && (i % 2) == 0) {
                ans++;
            } else if (S[i] == '0' && (i % 2) == 1){
                ans++;
            }
        }
    } else {
        for (int i = 1; i < S.length(); i++) {
            if (S[i] == '0' && (i % 2) == 0) {
                ans++;
            } else if (S[i] == '1' && (i % 2) == 1) {
                ans++;
            }
        }
    }
    cout << ans << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (n % 2 == 0 ? n : n * 2) << endl;
    
    return 0;
}


Measured memory_bytes: 256
s = input()
ans = 0
if s == 'SUN':
    ans = 7
elif s == 'MON':
    ans = 6
elif s == 'TUE':
    ans = 5
elif s == 'WED':
    ans = 4
elif s == 'THU':
    ans = 3
elif s == 'FRI':
    ans = 2
elif s == 'SAT':
    ans = 1
print(ans)

Measured memory_bytes: 9048