akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
#include<time.h>
#include<math.h>
#include<stdlib.h>
using namespace std;



int main() {
	int A[110], N,i,even=0,ans=0,odd=0;
	cin >> N;
	for (i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (i = 0; i < N; ++i) {
		if (A[i] % 2 == 0) {
			++even;
			if ((A[i] % 3 == 0) || (A[i] % 5 == 0)) {
				++ans;
			}
		}
		else { ++odd; }
		
	}
	if (((ans == even) && (even != 0))||odd==N) {
		cout << "APPROVED"<<endl;
	}
	else { cout << "DENIED" << endl; };
	return 0;
}

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

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

   cout << ceil((a + b) / 2) << endl;
}

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

int main()
{
	//input
	int A; cin >> A;
	int B; cin >> B;
	int C; cin >> C;
	int X; cin >> X;
	//compute
	int ans = 0;
	int x = X / 50;
	for (int a = 0; a <= A; a++){
		for (int b = 0; b <= B; b++){
			for (int c = 0; c <= C; c++){
				if (10 * a + 2 * b + c == x) ans++;
			}
		}
	}
	//output
	cout << ans << endl;
} 

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

using namespace std;
int main()
{

    int n;
    cin >> n;

    int t1[5] = {2, 4, 5, 7, 9};
    int t2[4] = {0, 1, 6, 8};

    int *p1 = find(t1, t1 + 5, n % 10);
    int *p2 = find(t2, t2 + 4, n % 10);

    if (p1 != t1 + 5)
        cout << "hon" << endl;

    else if (p2 != t2 + 4)
        cout << "pon" << endl;

    else
        cout << "bon" << endl;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main() {
    string s,ans = "";
    cin >> s;
    int c = 0;
    for(int i = 0;;i++){
        if(i == 0)ans += s[0];
        else if(!s[i+1]){
            ans += to_string(c) + s[i] + "\n";
            break;
        }
        else c++;
    }
    cout << ans;
    return 0;
}


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

int main() {
  cout << fixed << setprecision(10);
  int n,k; cin >> n >> k;
  int count=0;
  for(int i = k; i <= n; i++){
    count++;
  }

  //cout << count << endl;

  double ans=0;
  for(int i=1; i < min(n+1,k); i++){
    int cdn = i; int coin=0;
    while(cdn < k){
      cdn *= 2;
      coin++;
    }
    ans += (double)pow((double)0.5 , (double)coin);
    //cout <<"ans= " << ans << endl;
  }
  ans = (ans + count) / n;
  cout << ans << endl;
}


Measured memory_bytes: 256
import Data.List

main :: IO ()
main = do
  as <- map read . words <$> getLine
  let [a,b,c] = sort as
  print $ solve a b c

solve :: Int -> Int -> Int -> Int
solve a b c | even (c-a) && even (c-b) = (c-a) `div` 2 + (c-b) `div` 2
            | even (c-a) || even (c-b) = (c-a) `div` 2 + (c-b) `div` 2 + 2
            | otherwise = (c-a-1) `div` 2 + (c-b-1) `div` 2 + 1


Measured memory_bytes: 508
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}


fn main() {
    let n: usize = read_line().trim().parse().unwrap();
    let mut ans = 0;

    let mut m = 0;
    let mut tmp = n;
    while tmp > 0 {
        tmp /= 10;
        m += 1;
    }
    let mut tmp = 1;
    for i in 0..m {
        if i%2 > 0 {
            ans += tmp - tmp / 10;
        }
        tmp *= 10;
    }
    if m %2 > 0 {
        ans += n - tmp/10 + 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
a = int(input())
b = int(input())
c = int(input())
x = int(input()) 
ans = 0
        
for ia in range(a+1):
    for ib in range(b+1):
        for ic in range(c+1):
            num = 500*ia+100*ib+50*ic
            if num==x:
                ans+=1

print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<set>
#include<list>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<limits>
#include<unordered_map>
#include<cctype>
#include<complex>
#pragma warning(disable:4996)
using namespace std;

#define debug(i) cout<<"<debug> "<<#i<<" "<<i<<" <\\debug>"<<endl
#define mfor(i,a,b) for(int i=(a);i<=(b);i++)
#define mrep(i,a,b) for(int i=(a);i>=(b);i--)
#define lll __int128
#define Re register
#define mem(a,b) memset(a,(b),sizeof(a))
#define Design ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define endl '\n'
typedef pair<int, int> intpair;
typedef pair<long long int, long long int> llpair;
typedef long long int ll;
const int INF = 0x3f3f3f3f;
const long long int INFLL = 0x3f3f3f3f3f3f3f3f;

//#pragma comment(linker, "/STACK:1024000000,1024000000") 

const int maxn = 1e6 + 10;
int a[maxn];

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

map<int, bool>ext;

bool getdivor(int x)
{
	for (int i = 2; i * i <= x; i++)
	{
		if (x % i) continue;
		if (ext[i]) return false;
		ext[i] = true;
		while (x % i == 0)
		{
			x /= i;
		}
	}
	if (x != 1)
	{
		if (ext[x]) return false;
		ext[x] = 1;
		return true;
	}
	return true;
}

int main()
{
	Design;
	int n;
	cin >> n;
	mfor(i, 1, n) cin >> a[i];
	int t = a[1];
	bool f = true;
	mfor(i, 2, n)
	{
		int g = gcd(t, a[i]);
		if (g != 1)
		{
			f = false;
		}
		t = g;
	}
	sort(a + 1, a + 1 + n);
	mfor(i, 1, n)
	{
		if (!getdivor(a[i]))
		{
			f = false;
			break;
		}
	}
	if (t != 1) cout << "not coprime";
	else if (f) cout << "pairwise coprime";
	else cout << "setwise coprime";
}

Measured memory_bytes: 7060
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
d = dd(int)
c = dd(int)
for i in range(N - 1, -1, -1):
  d[a[i]] = i
  c[a[i]] += 1
c[0] = 0
ks = sorted(d.keys())
res = [0] * N
for i in range(len(ks) - 1, 0, -1):
  x = ks[i]
  y = ks[i - 1]
  c[y] += c[x]
  d[y] = min(d[y], d[x])
for i in range(len(ks)):
  x = ks[i]
  y = 0
  if i > 0: y = ks[i - 1]
  res[d[x]] += c[x] * (x - y)
for r in res: print(r)

Measured memory_bytes: 84404
import itertools
n, m, x = map(int, input().split())

c = []
d = []
for i in range(n):
	s = list(map(int, input().split()))
	d.append(s)
    
ans = 10**9
for i in range(1,n+1):
	for j in itertools.combinations(d,i):
		s = [0 for ii in range(m+1)]
		for k in j:
			for l in range(m+1):
				s[l] += k[l]
		y = min(s[1:])
		if y >= x:
			ans = min(ans,s[0])
            
if ans == 10**9:
	print (-1)
else:
	print (ans)


Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n;
  cin >> n;
  vl a(n);
  map<ll, int> s;
  bool flag = 1;
  rep(i, n) {
    cin >> a[i];
    s[a[i]]++;
    if (a[i] != 0) flag = 0;
  }

  if (flag) cout << "Yes" << endl;
  else if(s.size() == 2) {
    int i = 0;
    vector<int> v(2);
    for (auto&& j : s) {
      v[i++] = j.second;
    }
    if (!(v[0] == v[1]*2 || v[0]*2 == v[1])) {
      puts("No");
      return 0;
    }

    rep(i, 41) {
      int cnt = 0;
      cerr << i << endl;
      for (auto&& j : s) {
        if (j.first & (1LL << i)) cnt++;
      }

      if (cnt != 1 && cnt != 0) {
        cerr << 1;
        puts("No");
        return 0;
      }
    }

    puts("Yes");
  } else if(s.size() == 3) {
    int i = 0;
    vector<int> v(3);
    for (auto&& j : s) {
      v[i++] = j.second;
    }
    if (!(v[0] == v[1] && v[1] == v[2])) {
      puts("No");
      return 0;
    }


    rep(i, 41) {
      int cnt = 0;
      cerr << i << endl;
      for (auto&& j : s) {
        if (j.first & (1LL << i)) cnt++;
      }

      if (cnt != 2 && cnt != 0) {
        puts("No");
        return 0;
      }
    }

    puts("Yes");
  } else {
    cerr << 10 << endl;
    puts("No");
  }
}


Measured memory_bytes: 5760
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
    int n,a[100],s;
    while(cin >> n,n){
        s = 0;
        for(int i = 0;i < n;++i){
            cin >> a[i];
        }
        sort(a,a+n);
        for(int i = 1;i < n-1;++i){
            s += a[i];
        }
        cout << s/(n-2) << endl;
    }
    return 0;
}

Measured memory_bytes: 2992
#include<iostream>
using namespace std;
int go[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
int i, j, n, m, f[111][111];
char a[111][111];
int main()
{
	cin >> n >> m;
	for(i = 1; i <= n; i++)
		for(j = 1; j <= m; j++)
		{
			cin >> a[i][j];
			f[i][j] = 0;
		}
	for(i = 1; i <= n; i++)
		for(j = 1; j <= m; j++)
		{
			if(a[i][j] == '.'){
				if(a[i + 1][j] == '#') f[i][j] ++;
				if(a[i - 1][j] == '#') f[i][j] ++;
				if(a[i][j - 1] == '#') f[i][j] ++;
				if(a[i][j + 1] == '#') f[i][j] ++;
				if(a[i + 1][j + 1] == '#') f[i][j] ++;
				if(a[i - 1][j + 1] == '#') f[i][j] ++;
				if(a[i + 1][j - 1] == '#') f[i][j] ++;
				if(a[i - 1][j - 1] == '#') f[i][j] ++;
			}
		}
	for(i = 1; i <= n; i++)
	{
		for(j = 1; j <= m; j++)
			if(a[i][j] == '.') cout << f[i][j];
			else cout << a[i][j];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 764
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
const int N = 1e5+2;
int n,k;
int a[101];
int dp[N];
int solve(int rem)
{
    if(dp[rem]!=-1)
        return dp[rem];
    int res = 0;
    for(int i=0;i<n;i++)
    {
        if(rem-a[i]<0)
            break;
        res = res|(solve(rem-a[i])==0);
    }
    dp[rem] = res;
    return res;
}
signed main()
{
    fast;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    memset(dp,-1,sizeof(dp));
    int res = solve(k);
    if(res)
        cout<<"First";
    else cout<<"Second";
}

Measured memory_bytes: 4224
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


/** Problem1000 : A + B Problem **/
int main()
{
	int a, b;
	while (cin>>a>>b) {
		cout << a+b << endl;
	}
}

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

using namespace std;

int main()
{
    char A, B;
    cin>>A>>B;
    if(A=='H')
    {
        if(B=='H')
        {
            cout<<"H\n";
        }
        else
        {
            cout<<"D\n";
        }
    }
    else
    {
        if(B=='H')
        {
            cout<<"D\n";
        }
        else
        {
            cout<<"H\n";
        }
    }
    return 0;
}




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

using namespace std;

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

    int n;
    string s;
    cin >> n >> s;
    int ret = 0;
    for (int i = 0; i + 2 < n; ++i) {
        ret += s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C';
    }
    cout << ret << '\n';

    return 0;
}

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

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

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


int main(){
    string s;
    cin>>s;
    int a=0;
    rep(i,s.size()){
        if(s[i]!=s[s.size()-1-i]){
            a++;
        }
    }
    cout<<a/2<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace abc142_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] propaty = Console.ReadLine().Split(' ');
            int people = int.Parse(propaty[0]);
            int tall = int.Parse(propaty[1]);
            string[] stringData = Console.ReadLine().Split(' ');
            int[] intData = new int[people];
            int count = 0;
            for(int i = 0; i < people; i++)
            {
                    intData[i] = int.Parse(stringData[i]);
                if (intData[i] >= tall)
                {
                    count++;
                }
                else
                {

                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 16096
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

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

		if(n == 0){
			break;
		}

		int* start = new int[n];
		int* goal = new int[n];
		int* cost = new int[n];

		for(int i = 0; i < n; i++){
			cin >> start[i] >> goal[i] >> cost[i];
		}

		int town = 0;

		for(int i = 0; i < n; i++){
			town = max(town, max(start[i], goal[i]));
		}

		town++;

		vector<vector<int> > dist(town, vector<int>(town, INT_MAX / 2));

		for(int i = 0; i < n; i++){
			dist[start[i]][goal[i]] = cost[i];
			dist[goal[i]][start[i]] = cost[i];
		}

		for(int i = 0; i < town; i++){
			dist[i][i] = 0;
		}


		for(int k = 0; k < town; k++){
			for(int i = 0; i < town; i++){
				for(int j = 0; j < town; j++){
					dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		}
		int* total = new int[town];
		int TOTAL = INT_MAX / 2;
		int S = 0;

		for(int i = 0; i < town; i++){
			total[i] = 0;
		}

		for(int i = 0; i < town; i++){
			for(int j = 0; j < town; j++){
				total[i] += dist[i][j];
			}
			if(TOTAL > total[i]){
				TOTAL = min(TOTAL, total[i]);
				S = i;
			}
		}

		cout << S << " " << TOTAL << endl;
		delete [] start;
		delete [] goal;
		delete [] cost;
		delete [] total;
	}
	return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,h,w,ans=0;
    cin >> n >> h >> w;
    for (ll i=0;i<n;i++){
        ll a,b;
        cin >> a >> b;
        ans+=min(a/h,b/w);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a, b = (int(i) for i in input().split())
def f0(x):
    xx = (x + 1) % 4
    if xx == 0:
        return 0
    elif xx == 1:
        return x
    elif xx == 2:
        return 1
    else:
        return x^1
a = f0(a-1)
b = f0(b)
print(a^b)

Measured memory_bytes: 38256
#include <stdio.h>
#include <stdlib.h>
#include<time.h>

int main(void){
	int a,i,n,ans=0,max=0;
	scanf("%d",&n);
	int list[n];
	for(i=0;i<n;i++){
		scanf("%d",&a);
			list[i]=a;
			}
	for(i=0;i<n;i++){
		if(max<=list[i]){
			max=list[i];
			ans++;

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

}



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

 int main(){
   int n;
   cin >> n;
   vector <int> v(n);
   for (int i =0; i < n; i ++){
     cin >> v.at(i);
   }
   
   int count = 0;
   
 for(int i =0; i < n; i ++){
   for(int j =0; j < n; j ++){
     for(int k =0; k < n; k ++){
       if((v.at(i)!=v.at(j))&& (v.at(i)!=v.at(k))&&(v.at(j)!=v.at(k))&&((v.at(i)+v.at(j))>v.at(k))&&((v.at(k)+v.at(j))>v.at(i))&&((v.at(i)+v.at(k))>v.at(j))){
         count++; 
       }
       
     }
   }
 }
   cout << count/6 << endl;
 }

Measured memory_bytes: 3600
module Main where


main = do
  x <- readLn :: IO Integer
  print $ solve x

solve :: Integer -> Integer
solve x
  | x `mod` 11 == 0 = (x `div` 11) * 2
  | x `mod` 11 <= 6 = (x `div` 11) * 2 + 1
  | otherwise = (x `div` 11) * 2 + 2


Measured memory_bytes: 508
//Created Time:2019/12/9 8:57:49
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define mod 1000000007
#define ll long long

using namespace std;

ll f[100];

void init();
void work(ll, ll);
int calc(ll, ll, ll, ll);
ll read();

int main(){
	init(); int t; cin >> t;
	while(t--){
		ll x = read(), y = read();
		if(x > y) swap(x, y); work(x, y);
	}
	return 0;
}

void init(){
	f[1] = 1;
	for(int i = 2; i <= 88; ++i)
		f[i] = f[i - 1] + f[i - 2];
	return ;
}

int calc(ll x, ll y, ll a, ll b){
	int ans = ((y - b) / a + 1) % mod;
	if(b <= x) (ans += ((y - a) / b + 1) % mod) %= mod;
	return ans;
}

void work(ll x, ll y){
	if(x == 1){
		printf("%d %d\n", 1, y % mod);
		return ;
	}
	if(x == 2 && y == 2){
		puts("1 4");
		return ;
	}
	int pos = upper_bound(f + 1, f + 89, x) - f - 1;
	if(f[pos + 1] > y) --pos; printf("%d ", pos - 1);
	ll a = f[pos], b = f[pos + 1];
	int ans = calc(x, y, a, b);
	for(int i = 2; i < pos; ++i){
		ll na = a + f[pos - i] * f[i], nb = b + f[pos - i + 1] * f[i];
		if(na < a || nb < b || na > x || nb > y) continue;
		(ans += calc(x, y, na, nb)) %= mod;
	}
	printf("%d\n", ans);
	return ;
}

ll read(){
	ll x = 0; char ch = getchar();
	for(; !isdigit(ch); ch = getchar());
	for(; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	return x;
}

Measured memory_bytes: 3968
#include <stdio.h>

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

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

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", gcd(a, b));

	return 0;
}



Measured memory_bytes: 2672
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
int main(){
  int a,b;
  cin>>a>>b;
  int po=1;
  for(int i=0;i<=100;i++){
    if(po>=b)cout<<i<<endl,i=100;
    po+=a-1;
  }
    
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define int long long
#define vi vector<int> 
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >   
#define vpl vector< pair<ll,ll> >   
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define mod %1000000007
#define ld long double
#define pll pair<ll,ll>

int32_t main()
{
    IOS;
    /* #ifndef ONLINE_JUDGE
     freopen("int.txt","r",stdin);
     freopen("out.txt","w",stdout);
     #endif*/
     int n;
     cin>>n;
    vi a(n),b(n),c(n);
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];
    for(int i=0;i<n;i++)
        cin>>c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    vi bc(n+1,0);
    for(int i=0;i<n;i++)
    {
        bc[i]=c.end()-upper_bound(c.begin(),c.end(),b[i]);
       // trace2(i,bc[i]);
    }
    ll cc=0;
    for(int i=n-1;i>=0;i--)
    {
        cc+=bc[i];
        bc[i]=cc;
       // trace2(i,bc[i]);
    }
    vi ab(n);
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        ab[i]=b.end()-upper_bound(b.begin(),b.end(),a[i]);
        
        ab[i]=bc[n-ab[i]]-bc[n];
        ans+=ab[i];
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 4224
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,m]=i2()
c=[[] for i in range(n)]
for i in range(m):
 [a,b]=i2()
 c[a-1].append(b-1)
d=[]
e=0
for i in range(n):
 if i in d:
   e+=1
   d=[]
 if len(c[i]):
  d.append(min(c[i]))
print(e)

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

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

    char previous;
    previous = s[0];

        for (int i = 1; i < s.size(); i++){
            if (s[i] == '0') continue;
            if (s[i] == previous){
                s[i] = '0';
            }
            else {
                previous = s[i];
            }
        }

    // cout << s << "\n";
    
    int count = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] != '0') count++; 
    }
    
    cout << count << "\n";
    

}

Measured memory_bytes: 512
N = int(input())
n = int(N**0.5) + 1
a, b = 0, 0


for i in range(n, 1, -1):
  if N % i == 0:
    a, b = N // i, i
    break

if a == 0:
  a, b = N, 1

print(a + b - 2)

Measured memory_bytes: 3060
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    int main(){
        int n;cin>>n;
        auto sum = vec(int,n);

        rep(i,n){
            int w;cin>>w;
            if(i==0)sum[i] = w;
            else sum[i] = sum[i-1]+w;
        }
        int res = INF;
        rep(i,n){
            res = min(res,abs(sum[n-1]-2*sum[i]));
        }
        cout<<res;
    }
    


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define NIL -1

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

bool adj[105][105];
bool vis[105];
struct node{
	int ft;
	int rt;
};
node v[105];

int n;
int cnt;

void dfs (int cur )
{
	cnt++;
	vis[cur] = true;	
	v[cur].ft = cnt;
	for (int u = 1; u <= n; u++ ){
		if (!vis[u] && adj[cur][u] )
			dfs (u );
	} // end for
	cnt++;
	v[cur].rt = cnt;
}

int main()
{
	memset (adj, false, sizeof (adj ) );
	memset (vis, false, sizeof (vis ) );

	ios_base::sync_with_stdio(0);
	cin >> n;

	rep (i, n ) v[i].ft = NIL, v[i].rt = NIL;

	rep (i, n ){
		int v, k;
		cin >> v >> k;
		while (k-- ){
			int u; cin >> u;
			adj[v][u] = true;
		} // end rep
	} // end rep
	cnt = 0;
	while (true ){
		bool ok = true;
		for (int i = 1; i <= n; i++ ){
			if (v[i].ft == NIL ){
				dfs(i);
				ok = false;
				break;
			} // end if
		} // end for
		if (ok ) break;
	} // end while

	for (int i = 1; i <= n; i++ ){
		cout << i << ' ' << v[i].ft << ' ' << v[i].rt << endl;
	} // end for
	
	return 0;
}

Measured memory_bytes: 1216
from sys import stdin, stdout
from time import time
read = stdin.readline
write = stdout.write
flush = stdout.flush
xr = xrange

def main():
	animals, legs = map(int,read().split())
	if legs >= 2 * animals and legs <= 4 * animals and legs % 2 == 0:
		print 'Yes'
	else:
		print 'No'

if __name__ == "__main__":
	main()

Measured memory_bytes: 85036
n = int(input())
S = list(map(int, input().split()))

n = int(input())
T = list(map(int, input().split()))
cnt = 0

for i in T:
    left = 0
    right = len(S)-1
    center = int( (left+right) / 2 )

    while center >= left and center <= right:
        if S[center] == i:
            cnt += 1
            break
        elif S[center] > i:
            right = center-1
            center = int( (left+right) / 2 )
        elif S[center] < i:
            left = center+1
            center = int( (left+right) / 2 )

print(cnt)



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

int main(){
    int H,W;
    //複数のデータがあるので1個やったらまたもうひとつやらなきゃいけないのでbreakまで回す。
    while(1){
        cin >> H >> W ;
        //HとWがともに0となるときに限り、プログラムを終了する。
        if(H == 0 && W == 0){
            break;
        }else{
            //中のfor文をH回繰り返す。
            for(int i=0;i<H;i++){
                //W個＃を横に並べた。
                for(int k=0;k<W;k++){
                    if((i + k)% 2 == 0 ){
                        cout << "#" ;
                    }else{
                        cout << "." ;
                    }
                }
                //W番目のところで改行した。
                cout << endl;
            }
        }
        //新たな図形との間に空白をつくった。
        cout << endl;
    } 
    return 0;
}



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

int main()
{
    ll x=0,t=3;
    string ss;
    while(t--){
        string s;
        getline(cin,s);
        ss.push_back(s[x++]);
    }
    printf("%s\n", ss.c_str());
    return 0;
}

Measured memory_bytes: 3620
class RollingHash():
    def __init__(self, s):
        self.length = len(s)
        self.base = 1009
        self.mod = (1 << 127) - 1
        self.hash = [0] * (self.length + 1)
        self.pow = [1] * (self.length + 1)
 
        for i in range(self.length):
            self.hash[i+1] = (self.hash[i] + ord(s[i])) * self.base % self.mod
            self.pow[i+1] = self.pow[i] * self.base % self.mod
 
    def get(self, l, r):
        t = self.hash[r] - self.hash[l] * self.pow[r-l] % self.mod
        t = (t + self.mod) % self.mod
        return t
 
n = int(input())
s = input()
RH = RollingHash(s)
 
def check(l):
    place = {}
    for i in range(n - l + 1):
        hs = RH.get(i, i + l)
        if hs in place:
            if i - place[hs] >= l:
                return True
        else:
            place[hs] = i
    return False

l = 0; r = n // 2 + 1
while r - l > 1:
    m = (l + r) // 2
    if check(m):
        l = m
    else:
        r = m

print(l)

Measured memory_bytes: 46060
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll n,k,a=0,b=0;
	cin>>n>>k;
	for(int i=1;i<=n;++i){
		a+=i%k==0;
		if(k%2==0) b+=i%k==k/2;
	}
	ll res=a*(a-1LL)*(a-2LL)+b*(b-1LL)*(b-2LL);
	res+=a*(a-1LL)*3LL+b*(b-1LL)*3LL;
	res+=a+b;
	cout<<res;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <queue>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;


vector<int> G[105];
int d[105];
int f[105];
int tm = 0;
void dfs(int p){
    d[p]=tm;
    rep(i,G[p].size()){
        if(d[G[p][i]]==-1){
            tm++;
            dfs(G[p][i]);
        }
    }
    f[p] = ++tm;
    return;
}
int main(int argc, const char * argv[])
{
    int n;
    cin >> n;
    for(int i = 0;i <= n;i++) {
        d[i]=-1;
        f[i]=-1;
    }
    for(int i = 0;i < n;i++){
        int u,k;
        int to;
        scanf("%d %d",&u,&k);
        for(int j=0;j<k;j++){
            scanf("%d",&to);
            G[u].push_back(to);
        }
    }
    for(int i = 1;i <= n;i++){
        if(d[i]==-1){
            tm++;dfs(i);}
        
    }
    for(int i = 1;i <= n;i++){
        printf("%d %d %d\n",i,d[i],f[i]);
    }
}

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

const int Mod=1e9+7;

int N,M,Ans=1;
int To[15],F[1<<15];

int main(){
	int i,j,k,u,v,x;
	scanf("%d%d",&N,&M);
	while(M--){
		scanf("%d%d",&u,&v);
		To[u-1]|=1<<v-1;
		Ans=Ans*2%Mod;
	}
	F[0]=1;
	for(i=0;i<1<<N;i++)
		if((i&1)==(i>>1&1))
			for(j=i;j;j=j-1&i)
				if((j&1)==(j>>1&1)){
					for(x=1,k=0;k<N;k++)
						if(i>>k&1)
							x=1llu*x*((1<<__builtin_popcount(To[k]&(j>>k&1?i^j:j)))-(~j>>k&1))%Mod;
					F[i]=(F[i]+1llu*F[i^j]*x)%Mod;
				}
	printf("%d\n",(Ans-F[(1<<N)-1]+Mod)%Mod);
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <stack>
#include <numeric>
#include <cassert>
#include<map>
#include<bitset>

using lli = long long int;
lli inf = 1000000007;
using namespace std;

void teleporter(int N, lli K, vector<int> A) {
	int now = 0;
	for (int i = 0; i < K; i++) {
		now = A[now];
	}
	cout << (now+1) << endl;
}

void solve() {
	lli N, K;
	cin >> N >> K;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		A[i] -= 1;
	}

	// K <= N で愚直
	if (K <= N) {
		teleporter(N, K, A);
		return;
	}

	// 閉路の始点検出
	int now = 0;
	bool visit[200010] = {};
	while (true) {
		if (visit[now]) {
			break;
		}
		visit[now] = true;
		now = A[now];
	}

	// 閉路スタートまでのカウント
	int bef = 0;
	lli bef_c = 0;
	while (true) {
		if (bef == now) {
			break;
		}
		bef = A[bef];
		bef_c++;
	}
	K -= bef_c;

	// 閉路の周回時間カウント
	int cic = A[now];
	lli cic_c = 0;
	while (true) {
		if (cic == now) {
			break;
		}
		cic = A[cic];
		cic_c++;
	}
	K %= (cic_c + 1);

	// あとは愚直で間に合う
	int ans = now;
	for (int i = 0; i < K; i++) {
		ans = A[ans];
	}

	cout << (ans+1) << endl;

}

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

Measured memory_bytes: 4816
#include<cstdio>
int main()
{
	int sx,sy,tx,ty;
	while(~scanf("%d%d%d%d",&sx,&sy,&tx,&ty))
	{
		int path1,path2,k,p;
		if(sy<ty)
		{
			path1=ty-sy;
			k=path1;
			while(k--)
			{
				printf("U");
			}
		}
		else if(sy>ty)
		{
			path1=sy-ty;
			k=path1;
			while(k--)
			{
				printf("D");
			}
		}
		if(sx<tx)
		{
			path2=tx-sx;
			p=path2;
			while(p--)
			{
				printf("R");
			}
		}
		else if(sx>tx)
		{
			path2=sx-tx;
			p=path2;
			while(p--)
			{
				printf("L");
			}
		}
		if(sy<ty)
		{
			k=path1;
			while(k--)
			{
				printf("D");
			}
		}
		else if(sy>ty)
		{
			k=path1;
			while(k--)
			{
				printf("U");
			}
		}
		if(sx<tx)
		{
			p=path2;
			while(p--)
			{
				printf("L");
			}
		}
		else if(sx>tx)
		{
			p=path2;
			while(p--)
			{
				printf("R");
			}
		}
		if(sx<tx)
		{
			printf("L");
			path2++;
		}		
		else if(sx>tx)
		{
			printf("R");
			path2++;
		}		
		if(sy<ty)
		{
			path1++;
			k=path1;
			while(k--)
			{
				printf("U");
			}
		}
		else if(sy>ty)
		{
			path1++;
			k=path1;
			while(k--)
			{
				printf("D");
			}
		}
		if(sx<tx)
		{
			p=path2;
			while(p--)
			{
				printf("R");
			}
		}
		else if(sx>tx)
		{
			p=path2;
			while(p--)
			{
				printf("L");
			}
		}
		if(sy<ty)
			printf("D");
		else if(sy>ty)
			printf("U");
		if(sx<tx)
			printf("R");
		else if(sx>tx)
			printf("L");
		if(sy<ty)
		{
			k=path1;
			while(k--)
			{
				printf("D");
			}
		}
		else if(sy>ty)
		{
			k=path1;
			while(k--)
			{
				printf("U");
			}
		}
		if(sx<tx)
		{
			p=path2;
			while(p--)
			{
				printf("L");
			}
		}
		else if(sx>tx)
		{
			p=path2;
			while(p--)
			{
				printf("R");
			}
		}
		if(sy<ty)
			printf("U");
		else if(sy>ty)
			printf("D");
	}
	return 0;
 } 

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int f[11][11];
int main() {
	int n,d,cnt=0,t=0;
	cin>>n>>d;
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=d;j++) {
			cin>>f[i][j];
		}
	}
	//+return 0;
	for(int i=1;i<=n-1;i++) {
		for(int j=i+1;j<=n;j++) {
			for(int k=1;k<=d;k++) {
				t+=(f[i][k]-f[j][k])*(f[i][k]-f[j][k]);
			}
			int td=floor(sqrt(t));
			if(td*td==t) cnt++;
			t=0;
		}
	}
	cout<<cnt<<endl;
	return 0;
}
			
  	

Measured memory_bytes: 256
# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) (x&1)
typedef long long ll;
typedef long double ld;
const ll oo = /*2 * 1000 * 1000 * 1000*/0x3f3f3f3f;
const int _cnt = 1000 * 1000;
const int _p = 1000 * 1000 * 1000 + 7;
ll o(ll x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
//ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b)*b; }
using namespace std;

void file_put() {
	freopen("filename.in", "r", stdin);
	freopen("filename.out", "w", stdout);
}

struct ttype {
	int a, b;
};

int n;
ll k;
ttype T[200005];

bool cmp(const ttype &t1, const ttype &t2) {
	return t1.a < t2.a;
}

int main() {
	//file_put();

	scanf("%d%lld", &n, &k);
	for (int i = 1; i <= n; i++)  scanf("%d%d", &T[i].a, &T[i].b);
	sort(T + 1, T + n + 1, cmp);
	int t = 1;
	while (k > T[t].b) {
		k -= T[t].b;
		t++;
	}
	printf("%d\n", T[t].a);

	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b;
    cin>>a>>b;
    cout<<max({a+b,a-b,a*b})<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		int[] count = new int[101];
		while(stdIn.hasNext())
		{
			int n = stdIn.nextInt();
			++count[n];
		}
		int max = 0;
		for(int i = 0; i < count.length; ++i)
		{
			if(max < count[i])
			{
				max = count[i];
			}
		}
		for(int i = 0; i < count.length; ++i)
		{
			if(max == count[i])
			{
				System.out.println(i);
			}
		}
	}
}

Measured memory_bytes: 12000
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	REP(i,s.size()-1) {
		if(s[i]=='A'&&s[i+1]=='C') {
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
//*******************************By Harry Singh From Phillaur.
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000006
const ll mo=998244353;
#define string_to_any_base(s,base) stoll(s, 0, base);
#define vc vector
// #define mp map<ll,ll> mp;
#define bt(M,value) bitset<M> b(value)
#define S set<ll> s;
#define ST set<string> s;
#define INF 1e15
using namespace std;
set<ll> primes;
vector<pair<ll,ll>> adj[MAX];
vector<ll> ad[MAX];
///******************************ALL important functions;
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b);} 
ll lcm(ll a, ll b)  {  return (a*b)/gcd(a, b);  } 
ll power(ll x,ll y){ ll res = 1;x = x % mo; if (x == 0) return 0;while (y > 0){if (y & 1)  res = ((res%mo)*(x%mo)) % mo;  y = y>>1; x = ((x%mo)*(x%mo)) % mo;  }  return res;  }  
void Sieve(){ bool prime[MAX+1]; memset(prime, true, sizeof(prime)); for (int p=2; p*p<=MAX; p++) { if (prime[p] == true) {for (int i=p*p; i<=MAX; i += p) prime[i] = false; } } for(int i=2;i<=MAX;i++)if(prime[i]==true)primes.insert(i);} 
ll comb(ll N_, ll C_) {
	const int NUM_=400001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
ll modpow(ll a, ll n=mo-2) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

void solve() {
	int i,j,k,l,r,x,y,N,M,K; 
	cin>>N>>M>>K;
	
	ll sum=0;
	for(i=0;i<=K;i++) {
		sum+=comb(N-1,i)*M%mo*modpow(M-1,N-i-1)%mo;
	}
	cout<<sum%mo<<endl;
}
int main()
{
	solve();
}

Measured memory_bytes: 59860
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int n;
int cnt;

void init() {
	scanf("%d", &n);
	return ;
}

void solve() {
	for(register int i = 1; i <= n; i++) {
		if(i % 2 == 1) cnt++;
	}
	double ans = (double)cnt / (double)n;
	printf("%.10lf", ans);
	return ;
}

int main() {
	init();
	solve();
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll           long long
#define rep(i,j,n)   for(ll i=j;i<n;i++)
#define scn(a)       scanf("%lld",&a)
#define nl           printf("\n")
#define scns(a,b)    scanf("%lld %lld",&a,&b)
#define print(a)     printf("%lld",a)
#define tc           ll t; scn(t); while(t--)
#define vec          vector<ll>
#define pb           push_back
#define pairs        pair<ll,ll>
#define fi           first
#define se           second
#define all(v)       v.begin(),v.end()
#define srt(v)       sort(v.rbegin(),v.rend())
#define mem(a,b)     memset(a,b,sizeof(a))
#define maxx         5000005
#define inf          LLONG_MAX
#define zer          LLONG_MIN
#define dbug(a)      cout<<"dbug : "<<a<<endl
#define debug(a,b)   cout<<a<<" "<<b<<endl
#define read(v)      vec v(n,0); rep(i,0,n) {cin>>v[i];}
#define write(a,n)   rep(i,0,n) {cout<<a[i]<<" ";}
#define All          rep(i,0,n) 
ll zero = 0;




int main()
{
	
	ll n,m,k;
	cin>>n>>m>>k;
	
	
	cout<<((n-1)/m+1)*k;	
return 0;
}

Measured memory_bytes: 3552
#include <stdio.h>

int comp(char *str, char *S, int n, int j){
  char str0[10];

  if((j-n+1)<0) return 0;
  strncpy(str0, &S[j - n + 1], n);
  str0[n] = '\0';
  //printf("%d:%s\n", n,str0);
  if (strncmp(str0, str, n) == 0) {
    //printf("%s\n", str0);
    return 0;
  } else {
    return 1;
  }
}

int main() {
  char S[100010];
  int i, j, N, n;
  char str0[10];
  char str1[] = "dream";
  char str2[] = "dreamer";
  char str3[] = "erase";
  char str4[] = "eraser";
  int err = 0;

  scanf("%s", S);

  for (i = 0; i <= 100000; i++) {
    if (S[i] == '\0') {
      N = i - 1;
      break;
    }
  }

  n = 0;
  for (j = N; j >= 0; j = j - n) {
    //printf("j:%d\n", j);
    switch (S[j]) {
      case 'm':
        n = 5;
        err = comp(str1, S, n, j);
        break;
      case 'r':
        switch (S[j - 2]) {
          case 'm':
            n = 7;
            err = comp(str2, S, n, j);
            break;
          case 's':
            n = 6;
            err = comp(str4, S, n, j);
            break;
          default:
            err = 1;
            break;
        }
        break;
      case 'e':
        n = 5;
        err = comp(str3, S, n, j);
        break;
      default:
        err = 1;
        break;
    }
    //if(j-n < 0) err = 1;
    //printf("n:%d\n", n);
    if(err != 0){
      printf("NO");
      return 0;
    }
  }

  printf("YES");
  return 0;
}

Measured memory_bytes: 256
n = int(input().strip())
a = list(map(int, input().split()))
a = [0] + a + [0]
s = 0

for i in range(n + 1):
    s += abs(a[i + 1] - a[i])

for i in range(n):
    if (a[i] <= a[i + 1] <= a[i + 2]) or (a[i + 2] <= a[i + 1] <= a[i]):
        print(s)
    else:
        print(s - 2 * (min(abs(a[i + 2] - a[i + 1]), abs(a[i + 1] - a[i]))))


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

int cnt[100];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    long long k;
    cin >> s >> k;
    int n = s.length();
    if(n == 1){
        cout << k/2 << endl;
        return 0;
    }
    int p = 0;
    char pre = s[0];
    for(int i = 0; i < n; i++){
        if(s[i] == pre){
            cnt[p]++;
        }
        else{
            cnt[++p]++;
            pre = s[i];
        }
    }
    if(p == 0){
        cout << n*k/2 << endl;
        return 0;
    }
    long long ans = 0;
    for(int i = 0; i <= p; i++){
        ans += cnt[i]/2;
    }
    ans *= k;
    if(s[0] == s[n-1])
        ans -= (cnt[0]/2 + cnt[p]/2 - ((cnt[0]+cnt[p])/2)) * (k-1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n,l;
	cin >> n >> l;
	int a[n];
	REP(i,n){
		a[i] = l + i;
	}
	int mi = 1e9;
	int mem;
	REP(i,n){
		if(mi > abs(a[i])){
			mi = abs(a[i]);
			mem = a[i];
		}
	}
	int ans = 0;
	REP(i,n){
		ans += a[i];
	}
	cout << ans - mem << endl;
}

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

int main(){
  int N, K, a, b;
  cin >> N >> K;
  a = 1;
  for(int i = 0;i < N;i++){
    if(a * 2 <= a + K){
      a *= 2;
    }
    else{
      a += K;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    char c[] = new char[3];

    for(int i=0 ; i<3 ; i++){
      c[i] = s.charAt(i);
    }
    Arrays.sort(c);
    String d = new String(c);
    if(d.equals("abc")){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 22996
#include "bits/stdc++.h"

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

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

    if(n%2 == 0)cout << (n/2)* (n/2);
    else cout << (n/2)* (n/2 + 1
    );

    return 0;
}
//g++ -std=c++14 code1.cpp


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
//#include<iostream>
using namespace std;

int n,m;
#define maxn 200011
int a[maxn],b[maxn];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);sort(a+1,a+1+n);
	scanf("%d",&m);
	for (int i=1;i<=m;i++) scanf("%d",&b[i]);sort(b+1,b+1+m);
	int i=1,j;
	for (j=1;j<=m;j++)
	{
		while (i<=n && a[i]!=b[j]) i++;
		if (i>n) break;
		i++;
	}
	if (j<=m) puts("NO");
	else puts("YES");
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<string>
using namespace std;

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

	for (int i = 0; i < K; i++)
	{
		if (S[i] != '1') {
			cout << S[i] << endl;
			return 0;
		}
	}
	
	cout << 1 << endl;
	return 0;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++){
        cin >> s[i];
    }

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

    int ans;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            ans = 0;
            if (s[i][j] == '#'){
                continue;
            }
            
            for (int d = 0; d < 8; d++){
                const int ni = i + dy[d];
                const int nj = j + dx[d];
                if (ni < 0 || h <= ni){
                    continue;
                }
                if (nj < 0 || w <= nj){
                    continue;
                }
                if (s[ni][nj] == '#'){
                    ans++;
                }
            }
            s[i][j] = char(ans + '0');
        }
    }

    for (int i=0; i<h; i++){
        cout << s[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef set<int>        si;
typedef set<ii>         sii;

#define all(x) x.begin(),x.end()
#define clr(x,v) memset(x,v,sizeof x)
#define sz(x) (int)x.size()
#define forn(i,a,b) for(int i=a;i<b;i++)
#define re return

template<typename T> T sgn (T x)      {re x<0? -1:(x>0? 1:0); }
template<typename T> T gcd (T a, T b) {re a ? gcd (b % a, a) : b; }
template<typename T> T abs (T x)      {re x < 0 ? -x : x; }
template<typename T> T sqr (T x)      {re x*x;}

#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define ins insert
#define y second
#define x first
#define endl "\n"
#define MOD (int)1e9+7
#define N (int)2e5+123

int n;

void solve(){
    cin >> n;
}
int main(){_
    ll a,b;
    cin >> a >> b;
    cout<<(b>=a?"unsafe":"safe")<<endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  long long D;
  int Ans=0;
  cin>>N>>D;
  while(N--)
  {
    long long x,y;
    cin>>x>>y;
    if(sqrt(x*x+y*y)<=D)
      Ans++;
  }
  cout<<Ans<<endl;
  return 0;
}

Measured memory_bytes: 3644