akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int isPrimeNumber(int target_number);
 
int main ( void ) {
	int target_number = 0;
	int loop = 0;
	int Max_number = 0;
	int number_of_prime_numbers = 0;
	int flag_not_prime_number = 0;
	
	scanf ( "%d", &Max_number );
	for ( loop = 0; loop < Max_number; loop++ ) {
		scanf ( "%d", &target_number );
		flag_not_prime_number = isPrimeNumber(target_number);
		 
		if ( flag_not_prime_number == 0 ) {
			number_of_prime_numbers++;
		}
	}
	printf("%d\n", number_of_prime_numbers);
	return 0;
}

int isPrimeNumber(int target_number)
{
	
	int flag_not_prime_number = 0;
	int divisor = 2;
	
	
	if ( target_number == 4 ) {
		flag_not_prime_number = 1;
	}
	 
	while ( divisor*divisor <= target_number ) {
		if ( target_number % divisor == 0 ) {
			flag_not_prime_number = 1;
			break;
		}
		divisor++;
	}
	return flag_not_prime_number;
}


Measured memory_bytes: 2044
def main(str)
  t8, t10 = str.split(" ").map(&:to_i)
  (0..10**100).each do |i|
    i8  = (i * 0.08).floor
    i10 = (i * 0.10).floor
    return  i if i8 == t8 && i10 == t10
    return -1 if i8 > t8 && i10 > t10
  end
end

puts main($stdin.read.chomp)

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main(){
    int match[10]={0,2,5,5,4,5,6,3,7,6};
    int n,m;
    cin>>n>>m;
    int a[m],x[m];
    for(int i=0;i<m;i++)cin>>a[i];
    sort(a,a+m,greater<int>());
    for(int i=0;i<m;i++)x[i]=match[a[i]];
    vector<int>dp(n+1,-1000000000);
    dp[0]=0;
    for(int i=0;i<n-1;i++){
        for(int j=0;j<m;j++)if(i+x[j]<=n)dp[i+x[j]]=max(dp[i+x[j]],dp[i]+1);
    }
    while(n){
        for(int i=0;i<m;i++){
            if(n-x[i]>=0 && dp[n-x[i]]==dp[n]-1){
                cout<<a[i];
                n-=x[i];
                break;
            }
        }
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
set<char> seen;
char a[100], old[100];
int n;
int main()
{
	scanf(" %s", a);
	n = strlen(a);
	for (char i = 'a'; i <= 'z'; i++)
	{
		seen.insert(i);
	}
	for (int i = 0; i < n; i++) 
	{
		seen.erase(a[i]);
	}
	if (n == 26)
	{
		bool fails = false;
		for (int i = 0; i < n-1; i++)
		{
			if (a[i] < a[i+1]) fails = 1;
		}
		if (!fails)
		{
			printf("-1\n");
			return 0;
		}
		for (int i = 0; i < n; i++)
		{
			old[i] = a[i];
		}
		next_permutation(a, a+n);
		for (int i = 0; i < n; i++)
		{
			if (a[i] != old[i]) n = i+1;
		}
	}
	else
	{
		auto it = seen.begin();
		a[n++] = *it;
	}
	for (int i = 0; i < n; i++) printf("%c", a[i]);
	printf("\n");
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}


int cutvec(vi v, int N){
    int tmp1 = 1, tmp2 = 1;
    for (int i = N-1; i > 0; i--) {
        if (v[i-1] <= v[i]) {
            tmp1++;
        } else {
            break;
        }
    }

    for (int i = N-1; i > 0; i--) {
        if (v[i-1] >= v[i]) {
            tmp2++;
        } else {
            break;
        }
    }

    // cout << tmp1 << endl;
    // cout << tmp2 << endl;
    return max(tmp1, tmp2);
}

void solve(){
    int N;
    cin >> N;

    vi A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }


    int cutlen = 0;
    int ans = 0;
    int lenvec = A.size();
    while (lenvec != 0) {
        cutlen += cutvec(A, lenvec);
        lenvec = N - cutlen;
        ans++;
    }

    cout << ans << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 1024
N,Y = map(int,input().split())
for x in range(N+1):
    for y in range(N-x+1):
        if 10000*x+5000*y+1000*(N-x-y)==Y:
            print(x,y,N-x-y)
            exit()
x = -1
print(x,x,x)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

ll time2sec(string time){
    ll hour, min, sec;

    hour = 10*(time[0]-'0') + (time[1]-'0');
    min  = 10*(time[3]-'0') + (time[4]-'0');
    sec  = 10*(time[6]-'0') + (time[7]-'0');

    return 3600*hour + 60*min + sec;

}

int main(){
    while(true){
        ll n;
        cin >> n;
        if(n == 0)break;

        ll cnt[100000] = {};
        rep(i, n){
            string s, g;
            cin >> s >> g;

            cnt[time2sec(s)]++;
            cnt[time2sec(g)]--;
        }

        rep(i, 86400)cnt[i+1] += cnt[i];

        ll ans = 0;
        rep(i, 86410)ans = max(ans, cnt[i]);

        cout << ans << endl;
    }
}


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


int main(void)
{
	int n = 0;
	cin>>n;
	long long int a[n]={0};
	int four = 0;
	int two = 0;
	int oth = 0;
	int flag = 0;
	for(int k=0;k<n;k++){
		long long int h =0;
		cin>>h;
		a[k]=h;
	}
	for(int j=0;j<n;j++){
		if (a[j]%4 ==0) four++;
		else if (a[j]%2==0&&a[j]%4!=0) two++;
		else oth++;
	}
	if (two>0) flag = 1;
	if(flag+oth<=four+1) cout<<"Yes";
	else	cout<<"No";
	
	return 0;
}





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

using namespace std;

vector<int> v, an;
int bad[10];

bool ok(int x){
	while (x){
		if (bad[x % 10]) return 0;
		x /= 10;
	}
	return 1;
}

int main(){
//	freopen("input.inp", "r", stdin);
	int n, k;
	scanf("%d%d",&n,&k);
	for(int i = 1; i <= k; ++i){
		int x;
		scanf("%d",&x);
		bad[x] = 1;
	}
	for(int i = n; i <= 99999; ++i) if (ok(i)){
		printf("%d",i);
		break;
	}
	return 0;
}

Measured memory_bytes: 256
TH, TS, AH, AS = [int(s) for s in input().split(" ")]
turn = True
while True:
  if turn:
    AH -= TS
    if AH <= 0:
      print('Yes')
      break
    turn = not turn
  else:
    TH -= AS
    if TH <= 0:
      print('No')
      break
    turn = not turn

Measured memory_bytes: 9144
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]
INF = float('inf')


def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
        # A,B,Cに使用する材料を合成し、目的の長さの差を加算（必要なMP）
        # ret1-3で一つ目の材料にも合成魔法のMP10を要求しているので、A,B,Cの初回加算合わせて3回分のMP30を減算
        # a,b,cのいずれかが0のとき、材料が1つも宛がわれていない竹が存在するため、不適（必要MPをINFとして解にならないようにする）
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)
    # l[cur]について、使用しないか、(A,B,C)のいずれかに使用の4分岐


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<ll> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.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; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

// 最大公約数を求める
ll gcd(ll a,ll b){
	return b>0?gcd(b,a%b):a;
}
// 最小公倍数を求める
ll lcm(ll a,ll b){
	a = a/gcd(a,b);
	if(b!=0 && a>LONG_MAX/b) return 0;
	return a*b;
}
int n;
ll m;
main(){
	while(cin >> n >> m){
		vi a(n), p(n);
		REP(i, n) cin >> a[i];
		REP(i, n) cin >> p[i];
		vi dp(1<<n);
		REP(i, 1<<n){
			if(!i) continue;
			ll l=1;
			REP(j, n)
				if(l && (i>>j)&1) l = lcm(l, a[j]);
			dp[i] = l?m/l:0;
		}
//		REP(i, n)REP(j, 1<<n) if((j>>i)&1) dp[j] -= dp[j^(1<<i)];
		double ans = 0;
		REP(i, 1<<n){
			if(!i) continue;
			double pr=1.0;
			REP(j, n)
				if((i>>j)&1) pr *= p[j]/100.0;
//				else pr *= (100-p[j])/100.0;
			ans += (__builtin_popcount(i)&1?1:-1)*pr * abs(dp[i]);
		}
		printf("%.10f\n", ans);
	}
	return 0;
}

Measured memory_bytes: 9240
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;sc.hasNext();) {
			String str = sc.next();
			int joi = 0;
			int ioi = 0;
			for(int i=0;i<str.length()-2;i++) {
				if(str.charAt(i) == 'J' && str.charAt(i+1) == 'O' && str.charAt(i+2) == 'I')
					joi++;
				if(str.charAt(i) == 'I' && str.charAt(i+1) == 'O' && str.charAt(i+2) == 'I')
					ioi++;
			}
			System.out.println(joi);
			System.out.println(ioi);
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
@h=(<>!~$",sort{$b-$a}glob<>);map{$%=$h[$i=1]>>=1;@h[$i/2,$i]=@h[$i,$i/2]while$%<$h[$i+=$h[$i*=2]<$h[$i+1]]}1..$';$\+=$_ for@h;print

Measured memory_bytes: 31108
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n, k, x;
	cin >> n >> k;
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> x;
		ans += 2*min(x, k-x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (int)(n); i>=0; --i)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

int main()
{
    int X, Y;
    cin >> X >> Y;

    for(int x=0, y=X;x<=X;x++,y--)
    {
        if(x*2+y*4 == Y)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int root(vector<int> &par, int x){
  if(x == par.at(x)) return x;
  return par.at(x) = root(par, par.at(x));
}

bool same(int x,int y,vector<int> &par){
  return root(par,x) == root(par,y);
}

void unit(int x,int y,vector<int> &par){
  int rx = root(par,x);
  int ry = root(par,y);
  if(rx == ry) return;
  par.at(ry) = rx;
}

int main(){
  int n,k,l;
  cin >> n >> k >> l;
  vector<int> par(n);
  rep(i,n) par.at(i) = i;
  rep(i,k){
    int p,q;
    cin >> p >> q;
    p--;
    q--;
    unit(p,q,par);
  }
  vector<int> fam(n);
  rep(i,n) fam.at(i) = i;
  rep(i,l){
    int p,q;
    cin >> p >> q;
    p--;
    q--;
    //if(!same(p,q,par)) continue;
    unit(p,q,fam);
  }
  vector<pii> p(n);
  rep(i,n){
    p.at(i).first = root(par,i);
    p.at(i).second = root(fam,i);
  }
  //sort(p.begin(),p.end());
  map<pii,int> mp;
  rep(i,n){
    pii tmp = p.at(i);
    if(mp.count(tmp)) mp.at(tmp)++;
    else mp[tmp] = 1;
  }
  rep(i,n){
    //cout << root(par,i) << " ";
    pii tmp = p.at(i);
    cout << mp.at(tmp);
    if(i < n-1) cout << " ";
    //cout << fam.at(i) << " ";
  }
  cout << endl;
}


Measured memory_bytes: 15104
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i,n)cin >> a[i];
  rep(i,n)cin >> b[i];
  rep(i,n)cin >> c[i];

  ll ans = 0;
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());
  rep(i,n){
    int na = lower_bound(a.begin(),a.end(),b[i]) - a.begin();
    int nc = c.end() - lower_bound(c.begin(),c.end(),b[i]+1);
    ans += (ll)na*nc;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4572
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

hash = Hash.new {0}

A.each do |a|
  hash[a] += 1
end


diff = hash.keys.size - K
if diff <= 0
  puts 0
else
  puts hash.values.sort.take(diff).reduce(:+)
end


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

int gcd(int64_t x, int64_t y) {
    if(x < y) {
        int64_t tmp = x;
        x = y;
        y = tmp;
    }
    while(1) {
        int64_t q = x / y;
        int64_t r = x % y;
        if(r == 0) return y;
        x = y;
        y = r;
    }
}

int main() {
    int64_t n, m;
    cin >> n >> m;

    vector<int64_t> a(n);
    for(int64_t i = 0; i < n; i++) {
        cin >> a[i];
        a[i] /= 2;
    }
    sort(a.begin(), a.end());

    bool exist = true;
    int64_t num = 0;
    int64_t b = a[0];
    while(1) {
        if(b % 2 == 1) break;
        b >>= 1;
        num++;
    }
    for(int64_t i = 1; i < n; i++) {
        int64_t _num = 0;
        int64_t c = a[i];
        while(1) {
            if(c % 2 == 1) break;
            c >>= 1;
            _num++;
        }
        if(num != _num) {
            exist = false;
            break;
        }
    }

    int64_t lcm = a[0];
    for(int i = 1; i < n && lcm <= m; i++) lcm = lcm / gcd(lcm, a[i]) * a[i];

    if(!exist) {
        cout << 0 << endl;
    } else {
        cout << (m / lcm + 1) / 2 << endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    int r, g, b, n;
    cin >> r >> g >> b >> n;

    int ans = 0;
    for(int r_loop = 0; r_loop <= 3000; ++r_loop){
        for(int g_loop = 0; g_loop <= 3000; ++g_loop){
            int b_loop = n - r * r_loop - g * g_loop;
            if(b_loop >= 0){
                ans += (b_loop % b == 0);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
#define EPS 1e-9
#define DEBUG 0
#define ll long long
#define Pll pair<ll, ll>
#define Pii pair<int, int>
#define Pdd pair<double, double>
 
using namespace std;
struct edge{int from, to; ll cost;};

signed main(){
    ios::sync_with_stdio(false); cin.tie(0);
    string s;
    cin >> s;
    ll n = (ll)s.length();

    map<char,ll> mp;
    rep(n){
        mp[s[i]]++;
    }

    ll ans = (n-1)*n/2;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++){
        ll m = itr->second;
        ans -= (m-1) * m / 2;
    }
    cout << ans + 1;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;

#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

void Add(ll &a, ll b){
    a=(a+b)%mod;
    return;
}

void Pro(ll &a, ll b){
    a=(a*b)%mod;
    return;
}

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

Measured memory_bytes: 3620
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

//ABC164 C
int main() {
	int N;
	cin >> N;
	set<string> st;

	for (int i=0; i<N; i++) {
		string s;
		cin >> s;
		st.insert(s);
	}
	cout << st.size() << endl;
}

Measured memory_bytes: 19212
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

int f(int n){
    if(n%2)return 3*n+1;
    return n/2;
}

signed main(void) {
    vi a(1000005);
    cin >> a[1];
    loop(i,1,1000005){
        if(a[i] == 1 || a[i] == 2 || a[i] == 4){
            cout << i+3 << endl;
            return 0;
        }
        a[i+1] = f(a[i]);
    }

}


Measured memory_bytes: 8064
#include<iostream>
#include<cmath>
using namespace std;
int dp[100001]={-1};
int a[100001];
int n, k;
int f(int p)
{
	if(p==n-1)
		return 0;
	if(dp[p]!=-1)
		return dp[p];
	dp[p]=abs(a[p]-a[p+1])+f(p+1);
	for(int i = p+2; i < n && i <= p+k; i++)
	    dp[p]=min(dp[p], abs(a[p]-a[i])+f(i));
	return dp[p];
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin >> n >> k;
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		dp[i] = -1;
	cout << f(0) << '\n';
}

Measured memory_bytes: 5760
from collections import defaultdict
def a():
    A = []
    A += list(map(int,input().split()))
    A += list(map(int,input().split()))
    A += list(map(int,input().split()))
    N = int(input())
    d = defaultdict(int)
    for _ in range(N):
        d[int(input())] = 1

    B = list(map(lambda x:d[x],A))

    if sum(B[::4]) == 3:
        return 1
    
    if sum(B[2:8:2]) == 3:
        return 1
    
    for i in range(3):
        if sum(B[i*3:i*3+3]) == 3:
            return 1
        if sum(B[i::3]) == 3:
            return 1
    
    return 0

print(["No","Yes"][a()])


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

using namespace std;

string solve (int a, int b, int c) {

    if (a + b + c >= 22)
        return "bust";

    return "win";
}

int main() {

    int a, b, c;
    cin >> a >> b >> c;

    auto ans = solve (a, b, c);

    cout << ans << '\n';

    return 0;
}


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

typedef long long ll;

using namespace std;

int main(){
    int n;cin >> n;
    int check = 0;
    int ans = 0;
    for(int i = 0;i < n; i++){
        int x,y;
        cin >> x >> y;
        if(x != y)check = 0;
        else check ++;
        ans = max(ans, check);
    }
    if(ans >=3) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    while(true){
        int n, nMax, nMin; cin >> n >> nMin >> nMax;
        if(n == 0 and nMax == 0 and nMin == 0) return 0;
        else{
            vector<int> score(n);
            REP(i, n) cin >> score[i];
            int ans = 0, gap = 0;
            FOR(i, nMin, nMax + 1){
                if(score[i - 1] - score[i] >= gap){
                    gap = score[i - 1] - score[i];
                    ans = i;
                }
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 3068
def get_ints():
      return list(map(int,input().split()))

n = int(input())
a = get_ints()
b = get_ints()

cnt = [0]*(n+1)
for x in a+b:
  cnt[x] += 1

q = [set() for i in range(n+1)]
for i in range(1,n+1):
  if cnt[i] > n:
    print('No')
    exit(0)
  q[cnt[i]].add(i)
print('Yes')

def make_cnt(a):
  cnt_ = {}
  for i in range(n):
    if a[i] not in cnt_:
      cnt_[a[i]] = [i]
    else:
      cnt_[a[i]].append(i)
  return cnt_

cnt_a = make_cnt(a)
cnt_b = make_cnt(b)

def get_any(cnt_, x):
  for key in cnt_.keys():
    if key != x:
      return key
  assert False

ans = [-1]*n

for i in range(n,0,-1):
  s = list(q[i])
  x,y = 0,0
  if len(s) == 0:
    x = get_any(cnt_a, -1)
    y = get_any(cnt_b, x)
  elif len(s) == 1:
    x = s[0]
    if x not in cnt_a:
      y = x
      x = get_any(cnt_a, y)
    else:
      y = get_any(cnt_b, x)
  else:
    x,y = s
    if x not in cnt_a:
      x,y = y,x

  ans[cnt_a[x][-1]] = y
  def update_cnt(cnt_, x):
    cnt_[x].pop()
    if len(cnt_[x]) == 0:
      del cnt_[x]
  def use(x):
    q[cnt[x]].remove(x)
    cnt[x] -= 1
    q[cnt[x]].add(x)
  update_cnt(cnt_a, x)
  update_cnt(cnt_b, y)
  use(x)
  use(y)

print(' '.join(map(str,ans)))


Measured memory_bytes: 212712
#include <stdio.h>

int zettaiti(int num){
  if(num < 0)
    num = -num;
  
  return num;
}

int main(){
  
  int x, n;
  int p[100];
  int number[102] = {0};
  int i;
  int diff;
  int answer;
  
  scanf("%d %d", &x, &n);
  
  if(n == 0){
    printf("%d\n", x);
    return 0;
  }
  else{
    
    for(i = 0; i < n; i++){
      scanf("%d", &p[i]);
      number[p[i]] = 1;
    }   
    
    for(i = 0; i <= 101; i++){
      if(number[i] == 0){
        if(i == 0 || diff > zettaiti(x - i)){
          diff = zettaiti(x - i);
          answer = i;
        }
      }
    }
  }
  
  printf("%d\n", answer);
  
  return 0;
}

Measured memory_bytes: 1724
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
using namespace std;

int main(void){
 int N;
 long long int X;
 cin>>N;
 for(int i=0;i<N;i++){
  cin>>X;
  if(X%2==1){
   cout<<"first"<<endl;
   return 0;
  }
 }
 cout<<"second"<<endl;
 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  long long N,X;
  scanf("%lld%lld",&N,&X);
  if(X > N/2){
    X = N - X;
  }
  long long sum = 0;
  long long k;
  sum += X + N - X;
  N = N - X;
  while(X != 0){
    sum += 2*X*(N/X);
    k = N % X;
    N = X;
    X = k;
  }

  sum -= N;

  printf("%lld",sum);

}


Measured memory_bytes: 128
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner Sc=new Scanner(System.in);
    String s=Sc.next();
    int l=s.length();
    int y=0;
    for(int i=0;i<l-1;i++)
    {
      y=0;
      if(s.charAt(i)==s.charAt(i+1))
        y=1;
      if(y==1)
        break;
    }
    if(y==1)
      System.out.println("Bad");
    else
      System.out.println("Good");
  }
}


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

public class Main {

	Scanner sc = new Scanner(in);
	
	class Pair {
		int x, y;
		Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}
		@Override
		public boolean equals(Object o) {
			return this.x == ((Pair)o).x && this.y == ((Pair)o).y;
		}
	}
	
	class Node implements Comparable<Node> {
		int x, y, cost;
		Set<Pair> set;
		Node (int x, int y, int cost) {
			this.x = x;
			this.y = y;
			this.cost = cost;
			set = new HashSet<Pair>();
		}
		@Override
		public int compareTo(Node o) {
			return cost - o.cost;
		}
	}
	
	void run() {
		int[][] map = new int[20][20];
		PriorityQueue<Node> queue = new PriorityQueue<Node>();
		int[] dx = {0, 0, 1, -1};
		int[] dy = {1, -1, 0, 0};
		Pair[][] pairs = new Pair[20][20];
		for (int i = 0; i < 20; i++)
			for (int j = 0; j < 20; j++)
				pairs[i][j] = new Pair(i, j);
		t:while (true) {
			int w = sc.nextInt(), h = sc.nextInt();
			if (w == 0 && h == 0) break;
			int sx, sy;
			sx = sy = 0;
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++) {
					map[i][j] = sc.nextInt();
					if (map[i][j] == 2) {
						sx = i; sy = j;
					}
				}
			queue.clear();
			queue.add(new Node(sx, sy, 1));
			while (!queue.isEmpty()) {
				Node node = queue.poll();
				if (node.cost > 10) break;
				int x = node.x, y = node.y;
				for (int i = 0; i < 4; i++) {
					int c = 1;
					while (true) {
						if (x+c*dx[i] < 0 || y+c*dy[i] < 0 || x+c*dx[i] >= h || y+c*dy[i] >= w) {
							break;
						} else if (map[x+c*dx[i]][y+c*dy[i]] == 1 && !node.set.contains(pairs[x+c*dx[i]][y+c*dy[i]])) {
							if (c == 1) break;
							Node n = new Node(x+(c-1)*dx[i], y+(c-1)*dy[i], node.cost+1);
							n.set.addAll(node.set);
							n.set.add(pairs[x+c*dx[i]][y+c*dy[i]]);
							queue.add(n);
							break;
						} else if (map[x+c*dx[i]][y+c*dy[i]] == 3) {
							out.println(node.cost);
							continue t;
						} else {
							c++;
						}
					}
				}
			}
			out.println(-1);
		}

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

}

Measured memory_bytes: 105780
#include<stdio.h>
int main(void){
  double r, t, s, n;
  scanf("%lf", &r);
  t = 3.14159265359;
  s =  r * r * t;
  n = 2 * r * t;
  printf("%lf %lf\n", s, n);
  return 0;
}


Measured memory_bytes: 1996
N = int(input())
abc = [[0 for i in range(3)] for j in range(N)]
for i in range(N):
    a, b, c = map(int, input().split())
    abc[i] = a, b, c

dp = [[0 for i in range(3)] for j in range(N+1)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abc[i][k])

res = 0
for i in range(3):
    res = max(res, dp[N][i])

print(res)

Measured memory_bytes: 41744
#include <iostream>

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t , n , a, b, sum=0;

    cin >> a>>b;
    if(a>b)
    {
        cout << "safe";
        return 0;
    }
    cout << "unsafe";
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100000,mod=1e9+7;
vector<int>prime;
int check[MAXN+5],mob[MAXN+5];
void sieve()
{
    mob[1]=1;         //莫比乌斯函数筛
    for(int i=2;i<=MAXN;i++)
    {
        if(check[i]==0)
        {
            prime.push_back(i);
            mob[i]=-1;
        }
        for(int j=0;j<prime.size()&&i*prime[j]<=MAXN;j++)
        {
            check[i*prime[j]]=1;
            if(i%prime[j]==0)
            {
                mob[i*prime[j]]=0;
                break;
            }
            mob[i*prime[j]]=-mob[i];
        }
    }
}
int n,k;
long long qpow(long long a,long long b,long long mod){long long r=1,t=a; while(b){if(b&1)r=(r*t)%mod;b>>=1;t=(t*t)%mod;}return r;}
long long cal(int x)
{
    long long res=0;
    for(int i=1;i<=n/x;i++)(res+=mob[i]*qpow(n/x/i,k,mod))%=mod;
    return res;
}

int main()
{
    sieve();
    scanf("%d %d",&k,&n);
    long long ans=0;
    for(int i=1;i<=n;++i)(ans+=cal(i)*i)%=mod;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 4632
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
const int MOD = 1e9 + 7;

int gcd(int a, int b){ return ((b == 0) ? a : gcd(b, a % b)); }

int n, k;
ll ans = 1;
vi g[100005];

void dfs(int cur, int prev, int num){
	ans = (ans * num) % MOD;
	num = k - 1;
	if(prev != -1) num--;
	for(int u : g[cur]) if(u != prev){
		dfs(u, cur, num);
		num--;
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	cin >> n >> k;
	rep(i, n - 1){
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].pb(b);
		g[b].pb(a);
	}	
	dfs(0, -1, k);
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 7808
#include<stdio.h>
bool hs[10][10];
bool used[10][10];
int cx,cy;
int ans;
int nh;
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
int w,h;
void dfs(int x,int y,int f){
	if(f==nh){
		if(x==cx||y==cy)ans++;
		return;
	}
	int i,j;
	for(i=0;i<4;i++){
		for(j=1;j<10;j++){
			int nx=x+j*dx[i];
			int ny=y+j*dy[i];
			if(nx<0||nx>=h||ny<0||ny>=w)break;
			if(hs[nx][ny]){
				if(!used[nx][ny]){
					used[nx][ny]=true;
					dfs(nx,ny,f+1);
					used[nx][ny]=false;
					break;
				}
			}
		}
	}
}
int main(){
	while(1){
	int i,j;
	scanf("%d %d",&w,&h);
	if(w==0)return 0;
	for(i=0;i<h;i++)for(j=0;j<w;j++){
		hs[i][j]=false;
		used[i][j]=false;
	}
	nh=0;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			char c;
			scanf(" %c",&c);
			if(c=='1'){
				hs[i][j]=true;
				used[i][j]=false;
				nh++;
			}
			if(c=='2'){cx=i;cy=j;}
		}
	}
	ans=0;
	dfs(cx,cy,0);
	printf("%d\n",ans);
	}
}

Measured memory_bytes: 1028
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	//入力
        int x = sc.nextInt();
      	//入力が「1」の場合
        if (x == 1) {
            System.out.println(1);
            return;
        }
        int max = 1;
        for (int i = 2; i <= x; i++) {
          	//※Math.pow(i, j)は「iのj乗」
            for (int j = 2; (int)Math.pow(i, j) <= x; j++) {
            //最大値を出力  
              max = Math.max(max, (int)Math.pow(i, j));
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 35572
"""
NTC here
"""
import sys
inp = sys.stdin.readline
def input(): return inp().strip()
# flush= sys.stdout.flush
# import threading
# sys.setrecursionlimit(10**6)
# threading.stack_size(2**26)
 
def iin(): return int(input())
 
 
def lin(): return list(map(int, input().split()))
 
 
# range = xrange
# input = raw_input
 
def main():
    T = 1
    while T:
        T-=1
        k = iin()
        ans = [[0 for i in range(10)] for j in range(10)]
        for i in range(10):
            ans[0][i]=1
        for i in range(1, 10):
            for j in range(10):
                sm = ans[i-1][j]
                if j-1>=0:
                    sm+=ans[i-1][j-1]
                if j+1<10:
                    sm+=ans[i-1][j+1]
                ans[i][j] = sm
        # print(*ans, sep = '\n')
        br = 0
        i1, j1 = 0, 1
        for i in range(10):
            if br:break
            for j in range(1, 10):
                # print(i, j, k)
                if k<=ans[i][j]:
                    i1, j1 = i, j
                    br = 1
                    break
                else:
                    k-=ans[i][j]
        # print(i1, j1)
        sol = [str(j1)]
        for i in range(i1-1, -1, -1):
            chk = ([j1-1] if j1-1>=0 else []) + [j1] + ([j1+1] if j1+1<10 else [])
            for j in chk:
                if k<=ans[i][j]:
                    sol.append(str(j))
                    j1 = j
                    break
                else:
                    k-=ans[i][j]
        print(''.join(sol))





 
 
 
 
main()
 
# threading.Thread(target=main).start()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<=int(b);++i)
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {

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

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

int main(void) {
  int n,m;cin>>n>>m;
  int a[n+10];
  int tmp[n+10];

  ll l = 1;

  rep(i,0,n-1) {
    cin >> a[i];
    tmp[i] = a[i];
    l = lcm(l,a[i]);
  }

  while(true) {
    int mark = 0;
    rep(i,0,n-1) {
      if (tmp[i]%2==0) {
        mark++;
        tmp[i] = tmp[i] / 2;
      }
    }
    if(0 < mark && mark < n) {
      pr(0);
      return 0;
    }
    if(0 == mark) {
      break;
    }
  }

  ll ans=floor((m+l/2)/l);
  pr(ans);

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll	long long 
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
//cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
int gcd(int a, int b) 
{ 
	if(a>b)
	{
		swap(a,b);
	}
	if (a == 0) 
		return b; 
	return gcd(b % a, a); 
} 
int invertBits(int num) 
{  
    int x = log2(num) + 1; 
    for (int i = 0; i < x; i++)  
       num = (num ^ (1 << i));  
   
    return num; 
} 
///////////////////////////////////////////////////////////////////////////////////////////////////////////
string add(string f,string s)
{
    reverse(f.begin(),f.end());
    reverse(s.begin(),s.end());
    
    int i=0,j=0;
    string t="";
    int carry=0;
    while(i<f.size() && j<s.size())
    {
        int k=(f[i]-'0')+(s[j]-'0')+carry;
        carry=k/10;
        int sum=k%10;
        t+=(sum+'0');
        i++;
        j++;
    }
    while(i<f.size())
    {
        int k=(f[i]-'0')+carry;
        carry=k/10;
        int sum=k%10;
        t+=(sum+'0');
        i++;
    }
    
    while(j<s.size())
    {
        int k=(s[j]-'0')+carry;
        carry=k/10;
        int sum=k%10;
        t+=(sum+'0');
        j++;
    }
    
    if(carry)
    {
        t+=(carry+'0');
    }
    reverse(t.begin(),t.end());
    return t;
}
int mulmod(int a, int b, int mod) 
{ 
    int res = 0; // Initialize result 
    a = a % mod; 
    while (b > 0) 
    { 
        // If b is odd, add 'a' to result 
        if (b % 2 == 1) 
            res = (res + a) % mod; 
  
        // Multiply 'a' with 2 
        a = (a * 2) % mod; 
  
        // Divide b by 2 
        b /= 2; 
    } 
  
    // Return result 
    return res % mod; 
} 
int main()
{
	int mod =1000000007;
	int n,k;
	cin>>n>>k;
	int i;
	int b[n+1];
	vector<int> v[n+1];
	for(i=0;i<n-1;i++)
	{
		int s,d;
		cin>>s>>d;
		v[s].pb(d);
		v[d].pb(s);
	} 
	b[1]=k;
	int visited[n+1]={0};
	queue<pair<int,int> > q;
	q.push(mp(1,0));
	visited[1]=1;
	int prev=0,left=0;
	while(!q.empty())
	{
		pair<int,int> a=q.front();
		
		if(prev!=a.second)
		{
			prev=a.second;
			if(prev==1)
			{
				b[a.first]=k-1;
			}
			else
			{
				b[a.first]=k-2;
			}
			left=a.first;
		}
		else
		{
			if(a.first!=1)
			{
				b[a.first]=b[left]-1;
				left=a.first;	
			}
		}
		for(i=0;i<v[a.first].size();i++)
		{	
			if(!visited[v[a.first][i]])
			{
				visited[v[a.first][i]]=1;
				q.push(mp(v[a.first][i],a.first));
			}
		}
		q.pop();
	}
	int ans=1;
	for(i=1;i<=n;i++)
	{
		//cout<<b[i]<<" ";
		ans=mulmod(ans,b[i],mod);
	}
	cout<<ans%mod;
	return 0;
}


Measured memory_bytes: 7672
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n, k;
	int[] a;

	void run(){
		for(;;){
			n=sc.nextInt();
			k=sc.nextInt();
			if((n|k)==0){
				break;
			}
			a=new int[n];
			for(int i=0; i<n; i++){
				a[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		int[] sum=new int[n];
		sum[0]=a[0];
		for(int i=1; i<n; i++){
			sum[i]=sum[i-1]+a[i];
		}
		int max=Integer.MIN_VALUE;
		for(int i=0; i+k<n; i++){
			max=max(max, sum[i+k-1]-(i>0?sum[i-1]:0));
		}
		println(max+"");
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string t;
  cin>>t;
  int s=t.size();
  for(int i=0;i<s;i++){
    if(t[i]=='?'){
      t[i]='D';
    }
  }
  cout<<t<<endl;
  return 0;
}

Measured memory_bytes: 3732
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int dp[1001][1001];
const int mod = 1e9 + 7;
char A[1001][1001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int H, W;
	scanf("%d", &H);
	scanf("%d", &W);
	rep(i, H) scanf("%s", A[i]);

	dp[0][0] = 1;
	rep(h, H) {
		rep(w, W) {
			if (A[h + 1][w] == '.') dp[h + 1][w] = (dp[h + 1][w] + dp[h][w]) % mod;
			if (A[h][w + 1] == '.') dp[h][w + 1] = (dp[h][w + 1] + dp[h][w]) % mod;
		}
	}
	printf("%d", dp[H - 1][W - 1]);

	Would you please return 0;
}

Measured memory_bytes: 4992
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, x = list(map(int, input().split()))
    # 整数 N 個 (改行区切り)
    M = [int(input()) for i in range(n)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    mmin = min(M)

    reall = x - sum(M)

    cnt = n + int(reall // mmin)

    print(cnt)


resolve()

Measured memory_bytes: 38384
#include<stdio.h>

int main(){
    int N, i;
    int jpy;
    double sum=0, btc;
    char s[10];

    scanf("%d", &N);

    for(i=0; i<N; i++){
        scanf("%lf %s", &btc, &s);
        if(s[0] == 'B'){
            sum += btc * 380000.0;
        }else{
            sum += btc;
        }
    }
    printf("%lf", sum);

    return 0;
}

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

using namespace std;

int main () {
        int n, sum = 0, curs = 0;
        cin >> n;
        char str[n], curr;

        for (int i = 0; i < n; ++i) {
                cin >> str[i];
                if (curs == 0) {
                        curr = str[i];
                }

                if (curr == str[i]) {
                        curs++;
                } else {
                        sum++;
                        curr = str[i];
                        curs = 1;
                }
        }

        sum++;

        cout << sum << "\n";
}

Measured memory_bytes: 384
//ABC163 A

#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = s; i < (int)(n); i++)
const lint mod = 1000000007;


lint ans = 0;
lint n;
lint a[300000];


int main() {
  cin >> n;

/*   rep(i,n){
    scanf("%lld",&a[i]);
  } */
  double PI=3.14159265358979323846;
  
  printf("%lf\n",2*n*PI);
}


Measured memory_bytes: 3768
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main(){
  int w,h,count;
  queue<int> que;
  int xx[4]={1,0,-1,0};
  int yy[4]={0,1,0,-1};
  int pos;
  string tmap;
  while(true){
    cin >> w >> h;
    if(!w&&!h)
      break;
    int mmap[w+2][h+2];
    for(int x=0;x<w+2;x++){
      mmap[x][0] = -1;
      mmap[x][h+1] = -1;
    }
    for(int y=0;y<h+2;y++){
      mmap[0][y] = -1;
      mmap[w+1][y] = -1;
    }
        
    for(int y=0;y<h;y++){
      cin >> tmap;
      for(int x=0;x<w;x++){
	switch(tmap[x]){
	case '.':
	  mmap[x+1][y+1] = 0;
	  break;
	case '#':
	  mmap[x+1][y+1] = -1;	  
	  break;
	case '@':
	  mmap[x+1][y+1] = 1;
	  que.push(y*w+x);
	  break;
	}
      }
    }
    count = 1;
    while(!que.empty()){
      pos = que.front();
      for(int dir=0;dir<4;dir++){
	if (mmap[pos%w+xx[dir]+1][pos/w+yy[dir]+1]==0){
	  que.push(pos+yy[dir]*w+xx[dir]);
	  mmap[pos%w+xx[dir]+1][pos/w+yy[dir]+1] = 1;
	  count++;
	}
      }
      que.pop();
    }
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>

using namespace std;

int main(){
	int H,W;
	while(1){
		cin>>H>>W;
		if(H==0&&W==0)
			break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if((i+j)%2)
					cout<<".";
				else
					cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
		
	}
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
int main() {
	string x;
	int sum;
	cin>>x;
	while(x!="0") {
		sum=0;
		for(int i =0; i<x.length(); i++) {
			sum+=x[i]-48;
		}
		cout<<sum<<endl;
		cin>>x;
	}

	return 0;
}


Measured memory_bytes: 3180
from copy import copy
import random
import math
import sys
input = sys.stdin.readline
D = int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last = [0]*26
ans = [0]*D
score = 0
for i in range(D):
    ps = [0]*26
    for j in range(26):
        pl = copy(last)
        pl[j] = i+1
        ps[j] += s[i][j]
        for k in range(26):
            ps[j] -= c[k]*(i+1-pl[k])
    idx = ps.index(max(ps))
    last[idx] = i+1
    ans[i] = idx+1
    score += max(ps)
for k in range(1,40001):
    na = copy(ans)
    x = random.randint(1,365)
    y = random.randint(1,365)
    na[x-1] = na[y-1]
    last = [0]*26
    ns = 0
    for i in range(D):
        last[na[i]-1] = i+1
        ns += s[i][na[i]-1]
        for j in range(26):
            ns -= c[j]*(i+1-last[j])
    if k%100 == 1:
        T = 80-(79*k/40000)
    p = pow(math.e,-abs(ns-score)/T)
    if ns > score or random.random() < p:
        ans = na
        score = ns
for a in ans:
    print(a)

Measured memory_bytes: 83804
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int R,G,B,N;
    cin>>R>>G>>B>>N;
    ll ans=0;
    rep(i,N/R+1){
        rep(j,N/G+1){
            if((N-R*i-G*j)%B==0 && (N-R*i-G*j)>-1) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
	int n,x=0,y=0;
	cin>>n;
	x=n;
	while (x>=15){
		y=y+200;
	x=x-15;
	}
	cout<<(n*800-y);
	
	
	
}

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

int main()
{
	map<int,int>arr;
	bool nothing = false;
	int n; cin >> n;
	while (n--) {
		int a; cin >> a; arr[a]++;
	}
	for (auto s : arr) {
		if (s.second > 1) {
			nothing = true;
		}
	}
	if (nothing) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
	return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			a.begin(), a.end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define	MAX_QWORD		((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N, D, X;
	cin >> N >> D >> X;
	vector<int> A(N);
	REP(i, N) cin >> A[i];

	int ans = X;
	REP(i, N) {
		ans += (((D - 1) / A[i]) + 1);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int i;
    int I;
    int h=0;
    int rev;
    for(i=a;i<=b;i++){
        rev=0;
        I=i;
        while(I!=0){
            rev=rev*10+I%10;
            I=I/10;
        }
        if(rev==i)h++;
    }
    cout << h << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        class bb : IComparable<bb>
        {
            public int a;
            public int b;

            public int CompareTo(bb e)
            {
                return b.CompareTo(e.b);
            }
        }

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            bb[] v = new bb[N];

            string[] s = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                v[i] = new bb();
                v[i].a = i + 1;
                v[i].b = int.Parse(s[i]);
            }

            Array.Sort(v);

            for (int i = 0; i < N; i++)
            {
                Console.Write("{0} ", v[i].a);
            }

            Console.WriteLine();
        }
    }
}



Measured memory_bytes: 29268