akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        x: usize,
        a: usize,
    }
    println!("{}", if x < a { 0 } else { 10 });
}


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

ll powr(ll x, ll y)
{

    ll ret = 1;
    for(ll i = 0; i < y; i++) ret*=x;
    return ret;
}

int main()
{
   ll n;
    string ss;
    cin >> n >> ss;
    ll ans = 0;
    for(ll cut = 1; cut < ss.size(); cut++)
    {

        map<char,ll> m1,m2;
        //string v1,v2;
        ll cnt = 0;
        for(ll i = 0; i < cut; i++) m1[ss[i]]++;
        for(ll i = n-1; i >= cut; i--) m2[ss[i]]++;
        for(char x = 'a'; x <= 'z'; x++)
        {

            if(m1[x] > 0 && m2[x] > 0) cnt++;
        }
        ans = max(ans,cnt);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <bitset>
#include <cassert>

using namespace std;

char w[10][10];
int id1[10];
int id2[10];

void exit_() {
    cout << "Impossible\n";
    exit(0);
}

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            cin >> w[i][j];
    if (w[0][0] != '#' || w[n - 1][m - 1] != '#') {
        exit_();
    }
    for (int i = 0; i < n; ++i) {
        int j = 0;
        while (j < m && w[i][j] == '.')
            ++j;
        if (j == m) {
            exit_();
        }
        id1[i] = j;
        while (j < m && w[i][j] == '#')
            ++j;
        --j;
        id2[i] = j;
        for (j = j + 1; j < m; ++j)
            if (w[i][j] == '#') {
                exit_();
            }
    }
    for (int i = 1; i < n; ++i)
        if (id1[i] != id2[i - 1]) {
            exit_();
        }
    cout << "Possible\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

const int nax = 2e3 + 5;
int cnt[nax];
int n, x, y;

int main ()
{
    #ifdef Lollipop
        freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    cin >> n >> x >> y;
    for (int i = 1; i < n; i++){
        for (int j = i + 1; j <= n; j++){
            int d = min(j - i, abs(x - i) + abs(y - j) + 1);
            cnt[d]++;
        }
    }
    for (int i = 1; i < n; i++){
        cout << cnt[i] << endl;
    }
    return 0;
}




Measured memory_bytes: 256
X = int(input())

if 400 <= X <=599:
  print('8')
elif 600 <= X <=799:
  print('7')
elif 800 <= X <=999:
  print('6')
elif 1000 <= X <=1199:
  print('5')
elif 1200 <= X <=1399:
  print('4')
elif 1400 <= X <=1599:
  print('3')
elif 1600 <= X <=1799:
  print('2')
elif 1800 <= X <=1999:
  print('1')

Measured memory_bytes: 9188
def fib(n):
  memo = [0]*(n+1)
  def _fib(n):
    if n == 0:
      return 2
    elif n == 1:
      return 1
    if memo[n] != 0:
      return memo[n]
    memo[n] = _fib(n-1) + _fib(n-2)
    return memo[n]
  return _fib(n)
n = int(input())
print(fib(n))

Measured memory_bytes: 3060
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x)  ((int)x.size ())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define sqrt(x) sqrt (abs(x))
#define y0 y3451
#define y1 y4562
#define j0 j25624
#define j1 j45624
#define makeunique(x) sort(all(x)), (x).resize (unique(all(x)) - (x).begin())

typedef pair <int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef long double ld;
typedef unsigned int uint;
typedef vector <string> vs;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <vi> vvi;

template <class T> using _tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }
template <class T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }
template <class T> int sgn (T x) { re x > 0 ? 1 : (x < 0 ? -1 : 0); }

#define filename ""

const D pi = acos(-1.);
const int N = 2e5 + 20;
const int inf = 1e9 + 7;

int n, m, k;
int a[N];
int dp[N];

int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) scanf("%d", a + i);
	dp[0] = 0;
	for (int i = 1; i < n; i++) {
		dp[i] = inf;
		for (int j = 1; j <= k; j++)
			if (i - j >= 0)
				dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
	}
	cout << dp[n - 1];
	return 0;
}


Measured memory_bytes: 1024
/*.....Bismillahir Rahmanir Rahim.....*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define  sz(x)  (int)x.size()
#define  ff first
#define  ss second
#define  pii  pair<int,int>
using namespace std;

int  gcd(int a,int b) {
	return  (b==0)? a: gcd(b,a%b);
}
int dp[100005][3];
void solve(){ 
	int  n;  cin >> n ;
	int  a[1+n][3];
	for (int i=0;i<n;i++){
		for (int j=0;j<3;j++)
			cin >> a[i][j];
	}
	for (int i=0;i<n;i++){
		for (int j=0;j<3;j++){
			if (i==0)  dp[i][j] = a[i][j]; 
			else {
				for (int k=0;k<3;k++){
					if (j==k) continue;
					dp[i][j] = max(dp[i][j],dp[i-1][k] + a[i][j]);
				}
				
			}
		}
	}
	int res=0;
	res = max(res,dp[n-1][0]);
	res = max(res,dp[n-1][1]);
	res = max(res,dp[n-1][2]);
	cout << res << endl ; 
}

signed main() {
	solve();
    return 0;
}


Measured memory_bytes: 4992
A,B,M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
price = sorted(a)[0] + sorted(b)[0]
for i in range(M):
  x,y,c = map(int,input().split())
  price = min(price, a[x-1] + b[y-1] - c)
print(price)

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }


int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    int X;// たかだか32までをしらべればよい

    cin >> X;

    int j = 0;
    int ans = 1;
    int tmp;
    for(int i = 2; i < 33; i++){
        tmp = i*i;
        while(tmp <= X){
            chmax(ans, tmp);
            tmp = tmp * i;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;



int main() {
#ifdef LC
	assert(freopen("input.txt", "r", stdin));
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	priority_queue<int> l, r;
	l.push(0);
	r.push(0);
	while (n--) {
		int a, b;
		cin >> a >> b;
		l.push(a);
		r.push(-b);
	}
	ll answer = 0;
	while (l.size()) {
		answer += max(0, l.top() + r.top());
		l.pop();
		r.pop();
	}
	cout << 2 * answer << "\n";
	return 0;
}


Measured memory_bytes: 1276
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    ll a, b, c, d; cin >> a >> b >> c >> d;
    b -= a;
    for (int i = 0; i < n; i++) {
        if (c*(n - 1 - i) - d * i <= b && b <= -c * i + d * (n - 1 - i)) {
            puts("YES");
            return 0;
        }
    }
    puts("NO");
    return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 2010
#define P 998244353
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n,a[N],u,v,s[N][2],f[N<<1][N<<1];
char S[N];
void inc(int &x,int y){x+=y;if (x>=P) x-=P;}
int main()
{
	scanf("%s",S+1);
	n=strlen(S+1);
	for (int i=1;i<=n;i++) a[i]=S[i]-'0';
	for (int i=1;i<=n;i++) u+=2-a[i],v+=a[i];
	for (int i=1;i<=n;i++) s[i][0]=s[i-1][0]+2-a[i],s[i][1]=s[i-1][1]+a[i];
	f[0][0]=1;
	for (int i=0;i<=u;i++)
		for (int j=0;j<=v;j++)
		if (i|j)
		{
			if (s[min(n,i+j)][0]>=i&&s[min(n,i+j)][1]>=j)
			{
				if (i) inc(f[i][j],f[i-1][j]);
				if (j) inc(f[i][j],f[i][j-1]);
			}
		}
	cout<<f[u][v];
	return 0;
}

Measured memory_bytes: 60544
#include <stdio.h>

int main() {

  int m, f, r;
  int x;
  while(1) {

    scanf("%d %d %d", &m , &f , &r);
    x = m + f;
    if(m == -1 && f ==-1 && r == -1) {
      break;
    }

    if(m == -1 || f == -1) {
      printf("F\n");
    } else if(x >= 80) {
      printf("A\n");
    } else if (x >= 65) {
      printf("B\n");
    } else if(x >= 50) {
      printf("C\n");
    } else if ( x >=30) {
      if(r >= 50) {
	printf("C\n");
      } else {
	printf("D\n");
      }
    } else if (x < 30) {
      printf("F\n");
    }
  }
  return 0;
}



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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	char a; cin >> a;
	if (isupper(a)) {
		cout << "A" << endl;
	} else {
		cout << "a" << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int s;
	cin >> s;
	vector<int> a;
	a.push_back(s);
	set<int> st;
	st.insert(s);
	for (int i = 1; i <= 1000000; ++i) {
		if (a[i-1] % 2 == 0) {
			a.push_back(a[i-1] / 2);
		} else {
			a.push_back(3 * a[i-1] + 1);
		}
		if (st.count(a[i]) == 0) {
			st.insert(a[i]);
		} else {
			cout << i + 1 << '\n';
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  int n;
  char s[101], t[101];
  scanf("%d %s %s", &n, s, t);

  rep(i, 0, n) {
    printf("%c", s[i]);
    printf("%c", t[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>

using namespace std;


int main() {
    int n;
    cin >> n;

    for (int i = 1; i < n; i++) {
        for (int j = 1; i + j <= n; j++) {
            if (j > 1)cout << " ";
            int ret = 0;
            while (((j >> ret) & 1) == 0) ret++;
            cout << ret + 1;
        }
        cout << endl;
    }
    return 0;
}

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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main(){
	int n;
	cin >> n;
	int k = n;
	vector<int> t(n);
	REP(i, n) cin >> t[i];
	if(n >= 24){
		cout << 0 << endl;
		return 0;
	}
	vector<int> ptime;
	sort(ALL(t));
	REP(i, n-1){
		if(t[i] == t[i+1]){
			if(i != n-2 && t[i] == t[i+2]){
				cout << 0 << endl;
				return 0;
			}
			else{
				ptime.pb(t[i]);
				t.erase(t.begin()+i);
				t.erase(t.begin()+i);
				n -= 2;
			}
		}
	}
	int ans = 0;
	int d[24];
	REP(i, 1<<n){
		d[0] = 1;
		fill(d+1, d+24, 0);
		vector<int> listt;
		REP(j, ptime.size()){
			listt.pb(ptime[j]);
			listt.pb(24-ptime[j]);
		}
		REP(j, n){
			int bit = (i>>j)%2;
			if(bit){
				int time = t[j];
				if(d[time]==0){
					d[time] = 1;
					listt.pb(time);
				}
				else break;
			}
			else{
				int time = 24-t[j];
				if(d[time]==0){
					d[time] = 1;
					listt.pb(time);
				}
				else break;
			}
		}
		if(listt.size()!=k) continue;
		else{
			int c = 24;
			listt.pb(0);
			listt.pb(24);
			sort(ALL(listt));
			REP(i, listt.size()-1){
				c = min({c, listt[i+1]-listt[i], 24-listt[i+1]+listt[i]});
			}
			ans = max(ans, c);
		}
	}
	cout << ans << endl;
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<62)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
     int d;
    cin >> d;   //d=365

    const int contest=26;
    vector<int> c(contest);
    for(auto &x:c)
        cin >> x;

    vector<vector<int>> s(d,vector<int>(contest,0));
    for(int i=0;i<d;i++){
        for(int j=0;j<contest;j++)
            cin >> s.at(i).at(j);
    }

    vector<int> t(d);
    for(auto &x:t)
        cin >> x;
    
    vector<int> last(contest+1,0),satisfaction(d+1);
    satisfaction.at(0)=0;   
    for(int i=1;i<d+1;i++){
        int dissatis=0;
        int act=t.at(i-1);
        last.at(act)=i;
        for(int j=0;j<contest;j++){
            dissatis+=c.at(j)*(i-last.at(j+1));
        }
        satisfaction.at(i)=satisfaction.at(i-1)+s.at(i-1).at(act-1)-dissatis;

        cout << satisfaction.at(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 3684
#import heapq
#import itertools
#import math
#import numpy as np
#import sys

N = int(input())
S = list(input())
#A = list(map(int, input().split()))
#S = [input() for _ in range(H)]
#T = [list(map(int,input().split())) for _ in range(N)]
#sys.exit()

mae = ''
ans = 0
for s in S :
    if s == mae :
       pass
    else :
        ans += 1
    mae = s
print(ans)

Measured memory_bytes: 3956
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0]
b = [0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N+1):
    if a[i] > K:
        break
    while b[j] > K - a[i]:
        j-=1
    ans = max(ans,i+j)
print(ans)

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

int main(int argc, const char **argv)
{
  	std::string id1{0}, id2{0};
  	
  	std::cin >> id1;
  	std::cin >> id2;
 
	if ( !id2.compare(0, id1.size(), id1) )
      	std::cout << "Yes" << std::endl;
  	else std::cout << "No" << std::endl;

  	return 0;
}

Measured memory_bytes: 3132
#include <stdio.h>

int box[1000000];

int main() {
	int i, j, k;
	int n = 1000000;
	int count = 0;
	int m;

	box[0] = 1;

//	scanf("%d", &n);

	for(i = 0; i < n; i++)
		if(box[i] == 0) 
			for(j = 2; j * (i + 1) - 1 < n; j++)
				box[j * (i + 1) - 1] = 1;
		
//デバッグ用
/*
	for(i = 0; i < n; i++) 
		if(box[i] == 0)
			printf("%d\n", i + 1);
	putchar('\n');
*/
//ここまでデバッグ用

	while(scanf("%d", &m) != EOF){
		count = 0;
		for(i = 0; i < m; i++)
			if(box[i] == 0)
				count++;
		
		printf("%d\n", count);
	}
	return 0;
}

Measured memory_bytes: 4496
package main

import "fmt"

func main() {
	//youtube解説の丸パクリすんません
	var n int
	fmt.Scan(&n)
	hs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&hs[i])
	}
	ans := 0
	active := 0
	for i:=0; i<n; i++ {
		if hs[i] <= active {
			active = hs[i]
		} else {
			ans += hs[i] - active
			active = hs[i]
		}
	}
	fmt.Println(ans)
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n - h + 1) * (n - w + 1) << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		boolean ans = true;
		String s = sc.next();
		char c[] = s.toCharArray();
		for (int i = 0; i <= s.length() - 1; i++) {
			if (i == a && c[i] != '-') {
				ans = false;

			}

			if (i != a) {
				if (c[i] != '0' && c[i] != '1' && c[i] != '2' && c[i] != '3'
						&& c[i] != '4' && c[i] != '5' && c[i] != '6'
						&& c[i] != '7' && c[i] != '8' && c[i] != '9') {
					ans = false;
				}
			}
		}
		if(s.length()!=a+b+1){
			ans=false;
		}

if(ans){
	System.out.println("Yes");
}else{
	System.out.println("No");
}
	}
}

Measured memory_bytes: 22612
from queue import Queue

def solve(h, w, SS):
    m = {
        (x, y): S[x] == '.'
        for y, S in enumerate(SS)
        for x in range(len(S))
    }
    conditions = {
        (-1, 0): lambda x, y: x > 0,
        (1, 0): lambda x, y: x < w - 1,
        (0, -1): lambda x, y: y > 0,
        (0, 1): lambda x, y: y < h - 1
    }

    def calc_max_len(x0, y0):
        q = Queue(maxsize = h * w)
        q.put((x0, y0))
        d = {(x0, y0): 0}
        max_len = 0
        while not q.empty():
            x, y = q.get(block=False)
            for dx, dy in conditions:
                key = (x + dx, y + dy)
                if conditions[(dx, dy)](x, y) and m[key] and key not in d:
                    q.put(key)
                    d[key] = d[(x, y)] + 1
            if max_len < d[(x, y)]:
                max_len = d[(x, y)]
        return max_len

    return max(calc_max_len(x, y) for x, y in filter(lambda key: m[key], m))

_h, _w = map(int, input().split())
_SS = [input() for _ in range(_h)]
print(solve(_h, _w, _SS))


Measured memory_bytes: 3952
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;


int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  int sum=0;
  int S=0;
  for(int i=0; i<N; i++){
    cin >> A[i];
    sum += abs(A[i]-S);
    S = A[i];
  }
  sum += abs(S);
  int B;
  S = 0;
  for(int i=0; i<N-1; i++){
    B = sum;
    B -= abs(A[i]-S);
    B -= abs(A[i+1]-A[i]);
    B += abs(A[i+1]-S);
    cout << B << endl;
    S = A[i];
  }
  sum -= abs(A[N-2]-A[N-1]);
  sum -= abs(A[N-1]);
  sum += abs(A[N-2]);
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1664
<?php

fscanf(STDIN, "%d", $N);
$th = floor($N / 100);
$to = $N % 100;

if (($th >= 01 && $th <= 12) && ($to >= 01 && $to <= 12)) {
    echo 'AMBIGUOUS';
} elseif ($th >= 01 && $th <= 12) {
    echo 'MMYY';
} elseif ($to >= 01 && $to <= 12) {
    echo 'YYMM';
} else {
    echo 'NA';
}


Measured memory_bytes: 4728
count = 0

def merge(A, left, mid, right):
  global count
  n1 = mid - left
  n2 = right - mid
  L = A[left:left+n1]
  R = A[mid:mid+n2]
  L.append(float("inf"))
  R.append(float("inf"))
  i = 0
  j = 0
  numLeft = len(L)-1 # the number of L's elements
  for k in range(left, right):
    if R[j] < L[i]:
      A[k] = R[j]
      j += 1
      count += numLeft-i # the number of inversions to R[j]
    else:
      A[k] = L[i]
      i += 1

def mergeSort(A, left, right):
  if left + 1 < right:
    mid = int((left + right)/2)
    mergeSort(A, left, mid)
    mergeSort(A, mid, right)
    merge(A, left, mid, right)


def main():
  n = int(input())
  A = list(map(int, input().split()))
  mergeSort(A, 0, n)
  print(count)

if __name__ == "__main__":
  main()

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

using namespace std;

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

#define N 100010
#define M 200010
#define endl "\n"
#define mod 1000000007 

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(NULL);
	
	string s, t;
	
	cin >> s >> t;
	
	int mn = INT_MAX;
	for(int i = 0; i < s.size() - t.size() + 1; i++){
		int cnt = 0;
		for(int j = 0, k = i; j < t.size(); j++, k++){
			if(s[k] != t[j]) cnt++;
		}
		mn = min(mn, cnt);
		//cout << i << " " << cnt << endl;
	}
	
	cout << mn << endl;
	
	return 0;
}

Measured memory_bytes: 3620
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
A,B,K = map(int,input().split())

ans = []
for i in range(1,101):
    if A%i==0 and B%i==0:
        ans.append(i)

ans.sort(reverse=True)
print(ans[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jiglypuff
#define ld long double
#define itn int
#define pir pair<int, int> 
#define all(x) (x).begin(), (x).end()
#define str string
using namespace std;

lli gcd(lli a, lli b) { return (b == 0LL ? a : gcd(b, a % b)); }
ld dist(ld x1, ld y1, ld x2, ld y2)
{
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
lli S(lli a)
{
	return (a * (a + 1LL)) / 2;
}
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0, -1, -1, 1, 1 };
int dy[] = { 0, 0, 1, -1, -1, 1, -1, 1 };


const int N = 15;
const lli mod = 1e9 + 7;
const ld pi = acos(-1);
const int T = 238;
const ld e = 1e-6;

lli bp(lli a, lli b = mod - 2LL)
{
	lli ret = 1;
	while (b)
	{
		if (b & 1) ret *= a, ret %= mod;
		a *= a;
		a %= mod;
		b >>= 1;
	}
	return ret;
}
ostream& operator<<(ostream& c, pir a)
{
	c << a.fr << " " << a.sc;
	return c;
}



int n, m, x, c[N];
vector <int> a[N];
int b[N], pat = mod;
void gm(int i1)
{
	for (int i = 0; i < a[i1].size(); i++)
	{
		b[i] += a[i1][i];
	}
}
int main()
{
	fastio;
	cin >> n >> m >> x;
	for (int i = 0; i < n; i++)
	{
		cin >> c[i];
		for (int j = 0; j < m; j++)
		{
			int d;
			cin >> d;
			a[i].ad(d);
		}
	}
	for (int i = 0; i < (1 << n); i++)
	{
		memset(b, 0, sizeof(b));
		int sum = 0;
		for (int j = 0; j < n; j++)
		{
			if ((1 << j) & i) gm(j), sum += c[j];
		}
		bool bl = true;
		for (int j = 0; j < m; j++)
		{
			if (b[j] < x) bl = false;
		}
		if (bl) pat = min(pat, sum);
	}
	if (pat == mod) return cout << -1, 0;
	cout << pat << endl;
	return 0;
}


/*


  __
*(><)*
  \/ /
  ||/
--||
  ||
  /\
 /  \
/    \
*/



Measured memory_bytes: 3696
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from collections import deque


def main():
    N, M = map(int, input().split())
    adj_lists = {i: [] for i in range(1, N + 1)}
    for i in range(M):
        a, b = map(int, input().split())
        adj_lists[a].append(b)
        adj_lists[b].append(a)
    alreadys = np.zeros((N + 1, ))
    queue = deque()
    queue.append(1)
    while(len(queue) != 0):
        now = queue.popleft()
        nexts = adj_lists[now]
        for next_ in nexts:
            if alreadys[next_] != 0:
                continue
            alreadys[next_] = now
            queue.append(next_)
    for i in range(2, N+1):
        if alreadys[i] == 0:
            print('No')
            sys.exit()
    
    print('Yes')
    for i in range(2, N + 1):
        print(int(alreadys[i]))





if __name__ == '__main__':
    main()


Measured memory_bytes: 59056
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
int main()
{
    int n;string s;
    cin>>n>>s;
    if(s.size()<=n) cout<<s;
    else
    {
        for(int i=0;i<n;i++) cout<<s[i];
        cout<<"...";
    }
}


Measured memory_bytes: 3628
/*input
8 12 3
*/
#include<bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define MAX 100005
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define ff first
#define ss second
#define T int t;cin>>t;while(t--)
using namespace std;

signed main(){
    int a,b,k;
    cin>>a>>b>>k;
    int c = __gcd(a,b);
    int j = 0;
    for(int i=1;i<=c;i++){
        if(c%i == 0){
            j++;
        }
    }
    for(int i=1;i<=c;i++){
        if(c%i==0){
            if(j==k) cout << i << '\n';
            j--;
        }
    }
    return 0;
}


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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    ll N;
    Scll(N);

    ll t = 10;
    ll ans = 0;
    t = 5;
    while( N>=t ){
        ans += N/t/2;
        t *= 5;
    }

    if( N%2 ) ans = 0;
    printf ("%lld\n", ans );

    return 0;
}



Measured memory_bytes: 256
# ABC-087_B-Coins

A_num = int(input())
B_num = int(input())
C_num = int(input())
X_yen = int(input())
count = 0

for a in range(A_num+1):
    for b in range(B_num+1):
        for c in range(C_num+1):
            total = 500*a + 100*b + 50*c
            if total == X_yen:
                count += 1
print(count)

Measured memory_bytes: 3060
n=int(input())
d=list(map(int,input().split()))
d.sort()
m=int(input())
t=list(map(int,input().split()))
t.sort()
dd=d.pop()
tt=t.pop()
while d or t:
    if tt==dd:
        if t:
            tt=t.pop()
        else:
            print("YES")
            exit()
        if d:
            dd=d.pop()
        else:
            print("NO")
            exit()
        
    elif tt!=dd:
        if len(d)==0:
            print("NO")
            exit()
        dd=d.pop()
if dd==tt:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 122760
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        float[] ingredients = new float[N];
        for (int i = 0; i < N; i++) {
            int v = sc.nextInt();
            ingredients[i] = v;
        }
        Arrays.sort(ingredients);
        for (int i = 1; i < N; i++) {
            float composition = (ingredients[i - 1] + ingredients[i]) / 2;
            ingredients[i] = composition;
        }
        System.out.println(ingredients[N - 1]);
    }
}


Measured memory_bytes: 23764
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int n;
		int[] coins = new int[4];
		n = sc.nextInt();
		if (n == 0) return;
		while (true) {
			int sum = 0;
			for (int i = 0; i < 4; i++) {
				coins[i] = sc.nextInt();
				sum += coins[i];
			}
			
			int[] ans = new int[4];
			int min = 10000;
			for (int t = 0; t <= coins[0]; t++) {
				for (int f = 0; f <= coins[1]; f++) {
					for (int oh = 0; oh <= coins[2]; oh++) {
						for (int fh = 0; fh <= coins[3]; fh++) {
							int ch, n10, n50, n100, n500;
							n10 = n50 = n100 = n500 = 0;
							if ((ch = 10*t+50*f+100*oh+500*fh-n) >= 0) {
								n500 = ch/500;
								n100 = (ch-500*n500)/100;
								n50 = (ch-500*n500-100*n100)/50;
								n10 = (ch-500*n500-100*n100-50*n50)/10;
								if (min > sum-t-f-oh-fh+n500+n100+n50+n10) {
									min = sum-t-f-oh-fh+n500+n100+n50+n10;
									ans[0] = t;
									ans[1] = f;
									ans[2] = oh;
									ans[3] = fh;
								}
							}
						}
					}
				}
			}
			
			if (ans[0] > 0) out.printf("10 %d\n", ans[0]);
			if (ans[1] > 0) out.printf("50 %d\n", ans[1]);
			if (ans[2] > 0) out.printf("100 %d\n", ans[2]);
			if (ans[3] > 0) out.printf("500 %d\n", ans[3]);
			
			n = sc.nextInt();
			if (n == 0) return;
			
			out.println();
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 44692
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n; cin>>n;
	double x[10], y[10];
	vector<int> ind(n);
	for(int i=0; i<n; i++){
		ind[i]=i;
		cin>>x[i]>>y[i];
	}
	double s=0;
	do{
		for(int i=0; i<n-1; i++){
			int p=ind[i], q=ind[i+1];
			s+=sqrt(abs(x[p]-x[q])*abs(x[p]-x[q])+abs(y[p]-y[q])*abs(y[p]-y[q]));
		}
	}while(next_permutation(ind.begin(), ind.end()));
	for(int i=1; i<=n; i++) s/=i;
	printf("%.7lf\n", s);
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict, deque

H,W=map(int, sys.stdin.readline().split())
CH,CW=map(int, sys.stdin.readline().split())
CH-=1
CW-=1
DH,DW=map(int, sys.stdin.readline().split())
DH-=1
DW-=1
S=[ sys.stdin.readline().strip() for _ in range(H) ]

D=[(0,1),(0,-1),(1,0),(-1,0)]
WARP=[]
for dh in range(-2,3):
    for dw in range(-2,3):
        if abs(dh)+abs(dw)<=1: continue
        WARP.append((dh,dw))

d=defaultdict(lambda: float("inf")) #スタート地点から各マスまでの距離

q=deque()
q.append((0,CH,CW))
d[(CH,CW)]=0

while q:
    kyori, fro_h, fro_w=q.popleft()
    if (fro_h, fro_w)==(DH,DW):
        print d[(fro_h, fro_w)]
        quit()
    if d[(fro_h, fro_w)]<kyori: continue
    #歩いて移動
    for dh,dw in D:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori
                q.appendleft((kyori, to_h, to_w))
    #ワープ
    for dh,dw in WARP:
        to_h, to_w=fro_h+dh, fro_w+dw
        if 0<=to_h<H and 0<=to_w<W and S[to_h][to_w]==".":
            if kyori+1 < d[(to_h, to_w)]:
                d[(to_h, to_w)]=kyori+1
                q.append((kyori+1, to_h, to_w))

print -1


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

int main() {
    int w, a, b;
    cin >> w >> a >> b;

    if (a > b + w) cout << a - (b + w) << endl;
    else if (b > a + w) cout << b - (a + w) << endl;
    else cout << 0 << endl;

    return 0;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#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(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n,a;
	cin >> n >> a;
	vector<int> xUp;
	vector<int> xDown;
	int aCount = 0;
	FOR(i,0,n){
		int x;
		cin >> x;
		if(x > a){
			xUp.pb(x-a);
		}else if(x < a){
			xDown.pb(a-x);
		}else{
			aCount++;
		}
	}
	ll dpUp[50*n+1];
	ll dpDown[50*n+1];
	FOR(i,1,50*n+1)
		dpUp[i] = dpDown[i] = 0;
	dpUp[0] = dpDown[0] = 1;
	FOR(i,0,(int)xUp.size()){
		FORR(j,50*n-xUp[i],0){
			dpUp[j+xUp[i]] += dpUp[j];
		}
	}
	FOR(i,0,(int)xDown.size()){
		FORR(j,50*n-xDown[i],0){
			dpDown[j+xDown[i]] += dpDown[j];
		}
	}
	ll ans = 0;
	FOR(i,0,50*n+1){
		ans += dpUp[i] * dpDown[i] * pow(2,aCount);
	}
	ans--;
	ANS(ans);
}


Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
#define N 100000
int check(int);

int main(){

int total,A[N],i,num,cnt=0;

  scanf("%d",&total);

  for(i=0;i<total;i++){
    scanf("%d",&A[i]);
  }


  for(i=0;i<total;i++){
    num=check(A[i]);
    if(num==1)
      cnt++;
  }

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

int check(int A){
  int i;

  if( A == 2) return 1;
  if( A < 2 || A%2==0)return 0;

  i=3;
  while(i<=sqrt(A)){
    if(A%i==0)return 0;
    i=i+2;
  }

  return 1;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

ll gcd(ll a, ll b) {
	if (b > a) {
		swap(a, b);
	}
	ll r = a%b;
	while (r != 0) {
		a = b;
		b = r;
		r = a%b;
	}
	return b;
}

ll lcm(ll a, ll b) {
	return (a / gcd(a, b))*b;
}


int main() {
  ll n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  ll l = lcm(n, m);
  map<ll, int> mp;
  ll now = 1;
  rep (i, n) {
    mp[now] = i + 1;
    now += l / n;
  }
  now = 1;
  rep (i, m) {
    if (mp[now] == 0) {
      now += l / m;
      continue;
    }
    int j = mp[now] - 1;
    if (s[j] != t[i]) {
      cout << -1 << endl;
      return 0;
    }
    now += l / m;
  }
  cout << l << endl;
}


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

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, intmax_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, intmax_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N; cin >> N;

    constexpr int MOD = int(1e9) + 7;

    intmax_t res = 1;
    vector<intmax_t> c(3);
    for (size_t i = 0; i < N; ++i) {
        intmax_t a; cin >> a;
        intmax_t idx = -1, cnt = 0;
        if (a == c[0]) {
            cnt++;
            idx = 0;
        }
        if (a == c[1]) {
            cnt++;
            idx = 1;
        }
        if (a == c[2]) {
            cnt++;
            idx = 2;
        }
        if (idx == -1) {
            return cout << 0 << "\n", 0;
        }
        (res *= cnt) %= MOD;
        c[idx]++;
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
n=int(input())*9
# lis=list(map(int,input().split()))

vis={}
flag=1
a=1
t=10
while((7*(t))%n not in vis):
	k=(7*(t))%n
	vis[k]=1
	if(k==7):
		flag=0
		print(a)
		break
	a+=1
	t=(t*10)%n
	# print(k)
if(flag):
	print(-1)


Measured memory_bytes: 92676
N,K=[int(x) for x in input().split()]
A=[]
X=[]
Y=[]
for i in range(N):
  x,y=[int(x) for x in input().split()]
  A.append([x,y])
  X.append(x)
  Y.append(y)

X.sort()
Y.sort()
ans=(X[-1]-X[0])*(Y[-1]-Y[0])

for i in range(N):
  for j in range(i+1,N):
    for k in range(N):
      for l in range(k+1,N):
        x1=X[i]
        x2=X[j]
        y1=Y[k]
        y2=Y[l]
        count=0
        for a in range(N):
          if x1<=A[a][0] and A[a][0]<=x2:
            if y1<=A[a][1] and A[a][1]<=y2:
              count+=1
        if count>=K:
          ans=min(ans, (y2-y1)*(x2-x1))
print(ans)
   

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

int main() {
  int N, M;
  cin >> N >> M;
  vector <int> a (M);
  vector <int> b (M);
  vector <int> c (N);
  
  for (int i=0; i<M; i++){
    cin >> a.at(i) >> b.at(i);
    
    for (int j=0; j<N; j++){     
      if (a.at(i)==(j+1) || b.at(i)==(j+1)) {
      c.at(j) ++;
    }
    } 
  }
  for (int j=0; j<N; j++){     
     cout << c.at(j) << endl;
  }
 
}


Measured memory_bytes: 256
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n, k; cin >> n >> k;
	vector<int> q(n);
	rep(i, n)cin >> q[i];
	int res = 0;
	for (int i = 0; i <= min(n, k); ++i)
	{
		int r = min(n, k) - i;
		vector<int> minus;
		int tmp = 0;
		for (int j = 1; j <= i; ++j)
		{
			tmp += q[j - 1];
			if (q[j - 1] < 0)minus.push_back(q[j - 1]);
		}
		for (int j = 0; j <= r; ++j)
		{
			int tmp2 = tmp;
			vector<int> minus2 = minus;
			for (int l = 1; l <= j; ++l)
			{
				tmp2 += q[n - l];
				if (q[n - l] < 0)minus2.push_back(q[n - l]);
			}
			sort(all(minus2));
			for (int l = 0; l < min(k - i - j, (int)minus2.size()); ++l)tmp2 -= minus2[l];
			chmax(res, tmp2);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3596
/*input
6 5
8 6 9 1 2 1
1 3
4 2
4 3
4 6
4 6
*/

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

const int MAX_N = 100101;
const int MAX_M = 100101;

int main() {
    int N, M, H[MAX_N], A[MAX_M], B[MAX_M];
    cin >> N >> M;
    rep(i, N) cin >> H[i];
    rep(i, M) {
        cin >> A[i] >> B[i];
    }

    bool is_good[MAX_N];
    rep(i, N) is_good[i] = true;
    rep(i, M) {
        if (H[A[i]-1] <= H[B[i]-1]) is_good[A[i]-1] = false;
        if (H[B[i]-1] <= H[A[i]-1]) is_good[B[i]-1] = false;

    }

    int ans = 0;
    rep(i, N) {
        if (is_good[i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4896
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


int main() {
  ll n, p; cin >> n >> p;
  ll o = 0, e = 0;
  rep(i, 0, n){
    ll a; cin >> a;
    if(a%2 == 0) e++;
    else o++;
  }
  if(o == 0){
    if(p == 0) cout << (1LL << n) << endl;
    else cout << 0 << endl;
  }else{
    cout << (1LL << o-1) * (1LL << e) << endl;
  }


  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	Scanner sc = new Scanner(System.in);
	public void run() {
		while(sc.hasNext()){
			int a0 = sc.nextInt();
			int l = sc.nextInt();
			if(a0 == 0 && l == 0) break;
			calc(a0, l);
		}
	}

	public void calc(int a0, int l){
		int[] hairetsu = new int[(int) Math.pow(10, l)];
		Arrays.fill(hairetsu, -1);
		hairetsu[a0] = 0;
		int a = a0;
		int j = 1;
		while(true){
			int[] num = new int[10];
			for(int i = l-1; i > -1; i--){
				int hikaku = (int)Math.pow(10, i);
				if(hikaku > a) num[0] = num[0] + 1;
				else{
					int t = a / hikaku;
					num[t] = num[t] + 1;
					a = a - (t * hikaku);
				}
			}
			int max = 0;
			int min = 0;
			int count = l-1;
			int count2 = 0;
			for(int i = 9; i > -1; i--){
				while(num[i] > 0){
					max = max + ((int)Math.pow(10, count)) * i;
					min = min + ((int)Math.pow(10, count2)) * i;
					num[i] = num[i] - 1;
					count--;
					count2++;
				}
				if(count == -1) break;
			}
			a = max - min;
			if(hairetsu[a] != -1){
				System.out.println(hairetsu[a] + " " + a + " " + (j - hairetsu[a]));
				break;
			}
			else{
				hairetsu[a] = j;
				j++;
			}
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 89904