akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,c,d,e,f=0,i,j,k,l;
    cin>>a>>c>>d>>e;
    if(e<=a)
    {
        printf("%lld\n",e);
        return 0;
    }
    if(e<=(a+c))
    {
        f=a*1+(c*0);
        printf("%lld\n",f);
        return 0;
    }
    if(e<=(a+c+d))
    {
        d=e-(a+c);
        f=a*1+(c*0)+(d*-1);
        printf("%lld\n",f);
        return 0;
    }
    return 0;
}


Measured memory_bytes: 3764
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n, k = MAP()
a = [1] + LIST()

for i in range(k+1, n+1):
    if a[i] / a[i - k] <= 1:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 32656
from itertools import *
from bisect import *
from math import *
from collections import *
from heapq import *
from random import *
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]

def main():
    n=II()
    aa=LI()
    mn=1
    for a0,a1 in zip(aa,aa[1:]):
        if a0>=a1:mn+=1
    print(mn)
    print(n)

main()



Measured memory_bytes: 19908
#include<iostream>
using namespace std;
//const int inf =0x3f3f3f3f;
//struct node{
//	int cost;
//	int weight;
//}p[1010];
//int dp[10010] ;
//int n,m;
int main()
{
//	scanf("%d%d",&n,&m);
//	
//	
//	printf("%d %d\n",fg,jg);
	string s;
	cin >> s;
	if(s[0]=='S' ) cout <<"Cloudy" <<endl;
	else if(s[0]=='C' ) cout <<"Rainy" <<endl;
	else  cout <<"Sunny" <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

        signed main() {
        int n;
        cin>>n;
        int p[n];
        for(int i=0;i<n;i++)cin>>p[i];
        int ans=1;
        for(int i=1;i<n;i++){
            if(p[i-1]>=p[i])ans++;
            p[i]=min(p[i-1],p[i]);
        }
        cout<<ans;
         return 0;

        }


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

template <class Weight>
struct edge {
  using value_type = Weight;
  size_t src, dst;
  value_type cost;

  edge(size_t src, size_t dst, value_type cost=1):
    src(src), dst(dst), cost(cost)
  {}

  bool operator <(const edge<value_type> &rhs) const {
    if (cost != rhs.cost) return cost < rhs.cost;
    if (src != rhs.src) return src < rhs.src;
    return dst < rhs.dst;
  }
};

template <class Weight>
struct graph: public std::vector<std::vector<edge<Weight>>> {
  using value_type = Weight;
  graph(size_t n): std::vector<std::vector<edge<value_type>>>(n) {}

  void connect_with(size_t src, size_t dst, value_type cost=1) {
    (*this)[src].emplace_back(src, dst, cost);
    (*this)[dst].emplace_back(dst, src, cost);
  }

  void connect_to(size_t src, size_t dst, value_type cost=1) {
    (*this)[src].emplace_back(src, dst, cost);
  }
};

int main() {
  size_t n;
  scanf("%zu", &n);

  graph<int> g(n);
  for (size_t i = 1; i < n; ++i) {
    size_t u, v;
    scanf("%zu %zu", &u, &v);
    --u;
    --v;
    g.connect_with(u, v);
  }

  std::vector<int> c(n);
  for (auto& ci: c) scanf("%d", &ci);

  std::priority_queue<int> pq;
  for (auto ci: c) pq.push(ci);
  std::vector<int> res(n);

  std::queue<size_t> q;
  q.push(0);
  while (!q.empty()) {
    size_t v = q.front();
    q.pop();
    res[v] = pq.top();
    pq.pop();

    for (auto const& e: g[v]) {
      size_t nv = e.dst;
      if (res[nv] > 0) continue;
      q.push(nv);
    }
  }

  int sum = 0;
  for (size_t i = 1; i < n; ++i) sum += res[i];
  printf("%d\n", sum);
  for (size_t i = 0; i < n; ++i)
    printf("%d%c", res[i], i+1<n? ' ':'\n');
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007
vi adj[234567];
bool vis[234567];
int aoki[234567];
int taka[234567];

void dfs_aoki(int node)
{
	vis[node] = true;

	for (int child : adj[node])
	{
		if (!vis[child])
		{
			aoki[child] += aoki[node] + 1;
			dfs_aoki(child);
		}
	}
}

void dfs_taka(int node)
{
	vis[node] = true;

	for (int child : adj[node])
	{
		if (!vis[child])
		{
			taka[child] += taka[node] + 1;
			dfs_taka(child);
		}
	}
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, u, v;
	cin >> n >> u >> v;
	zip(i, 0, n - 1)
	{
		int a, b;
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	dfs_taka(u);
	rep(i, 1, 234566)
	{
		vis[i] = 0;
	}
	dfs_aoki(v);
	//cout << v << en;
	int ans = 0;
	// rep(i, 1, n)
	// {
	// 	cout << taka[i] << " ";
	// }
	// cout << en;
	// rep(i, 1, n)  cout << aoki[i] << " "; cout << en;
	rep(i, 1, n)
	{
		if (taka[i] < aoki[i])
		{
			ans = max(ans, aoki[i] - 1);
		}
	}
	cout << ans << en;


	return 0;

}



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

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

	int rains = 0;
	bool continue_flag = false;
	for(int i=0; i<3; i++) {
		if(w.at(i) == 'R') {
			if(continue_flag) {
				rains += 1;
			}
			else {
				if(rains==0) {
					rains = 1;
				}
				continue_flag = true;
			}
		}

		else {
			continue_flag = false;
		}
	}

	cout << rains << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#include <iomanip>
#include <limits>
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

int main()
{
	ll a, b, g;
	cin >> a >> b;
	g = gcd(a, b);
	auto f = factorize(g);
	int ans = f.size() + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;
using P = pair<int, int>;
template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 2 - 170;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    map<P, int> v;
    vector<ll> v2(10, 0);
    for (int i = 0; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        for (int j = 0; j <= 2; ++j) {
            for (int k = 0; k <= 2; ++k) {
                if(a-j>=1 && b-k>=1 && a-j+2 <= h && b-k+2 <= w){
                    v[make_pair(a-j, b-k)]++;
                }
            }
        }
    }
    for (auto &&a : v) {
        v2[a.second]++;
    }
    ll k = (ll)(h-2)*(w-2);
    for (int i = 1; i <= 9; ++i) {
        k -= v2[i];
    }
    v2[0] = k;
    for (auto &&item : v2) {
        cout << item << "\n";
    }
    return 0;
}


Measured memory_bytes: 56448
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    L, R = map(int, input().split())

    if R - L > 5000:
        print(0)
        return

    ans = INF
    for i in range(L, R + 1):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39280
def main():
    N, M = (int(_) for _ in input().split())
    a = []
    output = 0
    for p in range(1, int(M**.5)+1):
        if M%p == 0:
            a.append(p)
            a.append(M//p)
    for p in a:
        if M//p >= N: output = max(output, p)
    print(output)
    return

if __name__ == '__main__':
    main()


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

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

int main()
{

    int n;
    cin >> n;
    int ara[n][26];
    mset(ara,0);
    for(int i=0; i < n; i++)
    {

        string ss;
        cin >> ss;
        for(int j=0; j < ss.size(); j++)
        {

            int x = ss[j] - 'a';
            ara[i][x]++;
        }
    }
    int ans[26];
    mset(ans,0);
    for(int i=0; i < 26; i++)
    {

        int x = 1e9;
        for(int j=0; j < n; j++) x = min(x, ara[j][i]);
        ans[i]=x;
    }
    string ret;
    for(int i=0; i < 26; i++)
    {

        char c = 'a'+i;
        for(int j=0; j < ans[i]; j++) ret.pb(c);
    }
    cout << ret;
}


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

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

    cout << (n + 1) * n / 2 - n << endl;
}

Measured memory_bytes: 256
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

B = [A[0]]
for i in range(1,N-1):
    B.append(gcd(B[-1], A[i]))

C = [A[-1]]
for i in range(N-2,0,-1):
    C.append(gcd(C[-1], A[i]))

MAX = 0
for i in range(N):
    if i == 0:
        MAX = max(MAX, C[-1])
    elif i == N-1:
        MAX = max(MAX, B[-1])
    else:
        MAX = max(MAX, gcd(B[i-1], C[N-i-2]))

print(MAX)

Measured memory_bytes: 16128
n = int(input())
A =list(map(int, input().split()))

dp = [[0]*2 for _ in range(n)]
# dp[i][0]:*1
# dp[i][1]:*(-1)
for i in range(n-1):
    if i == 0:
        dp[i+1][0] += A[i]
        dp[i+1][1] += -A[i]
    else:
        dp[i+1][0] = max(dp[i][0]+A[i], dp[i][1]+(-1)*A[i])
        dp[i+1][1] = max(dp[i][0]+(-1)*A[i], dp[i][1]+A[i])
ans = max(dp[n-1][0]+A[n-1], dp[n-1][1]+(-1)*A[n-1])
print(ans)


Measured memory_bytes: 31208
//atRto TLH
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define ll long long
const ll MOD = 1e9 + 7;
#define ln '\n'
#define all(x) (x).begin(), (x).end()
#define rotate rotate(vec.begin(), vec.begin() + k, vec.end())
#define alloc(v) set<int> S(all(v))
#define bitset(n)  bitset<20>(n)
#define Min min({a, b, c, d})
 
      const ll INF=2*1e5;
      char tt[2003][2003];
    
     int vis[107];
     //vector<ll>v[107];
    int size=0;
 

 
 ll t[102][100007];
 
 
ll knapsack(ll W,ll n,ll a[],ll b[])
{
  for(ll i=0;i<n+1;i++) t[i][0]=0;
  for(ll i=0;i<W+1;i++) t[0][i]=0; 
 
 for(ll i=1;i<n+1;i++){
  for(int j=1;j<W+1;j++){
      if(a[i-1]<=j){
      t[i][j]=max(b[i-1]+t[i-1][j-a[i-1]],t[i-1][j]);
     }
     else
      t[i][j]=t[i-1][j];
  }
 }
return t[n][W];
}
    
 
    int main() {
      IOS;
    #ifndef ONLINE_JUDGE
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif
   
   memset(t,0,sizeof(t));
   ll n,W;
   cin>>n>>W;
   ll a[n],b[n];
   for(ll i=0;i<n;i++){
    cin>>a[i]>>b[i];
   }
   cout<<knapsack(W,n,a,b)<<ln;
   return 0;
 }

Measured memory_bytes: 83316
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
vector<int> G[100005];
int arrived[100005];
int D[100005];
int main() {
  ios::sync_with_stdio(false);
  int N, M, A, B;
  cin >> N >> M;
  for (int i=0; i<M; i++) {
    cin >> A >> B;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  queue<int> q;
  q.push(1);
  arrived[1] = 1;
  while (!q.empty()) {
    int v = q.front(); q.pop();
    int d = D[v];
    for (int i=0; i<G[v].size(); i++) {
      int u = G[v][i];
      if (arrived[u]) continue;
      q.push(u);
      arrived[u] = 1;
      D[u] = d + 1;
    }
  }
  cout << "Yes" << "\n";
  for (int i=2; i<=N; i++) {
    for (int j=0; j<G[i].size(); j++) {
      if (D[G[i][j]] == D[i] - 1) {
        cout << G[i][j] << '\n';
        break;
      }
    }
  }
}

Measured memory_bytes: 10848
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int A, B;
    cin >> A >> B;
    for(int i = 1; i <= 3; i++) {
        if(i != A && i != B) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import itertools

s = input()
memo = list(itertools.product(['', '+'], repeat=len(s) - 1))
ans = 0
check = []
cnt = ''

for i in range(2 ** (len(s) - 1)):
    check = []
    cnt = ''
    for j in range(len(s) - 1):
        cnt += s[j]
        if memo[i][j] == '+':
            check.append(int(cnt))
            cnt = ''

    cnt += s[len(s) - 1]
    check.append(int(cnt))
    ans += sum(check)

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<int>> a(N, vector<int>(M));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < M; ++j) {
			cin >> a[i][j]; --a[i][j];
		}
	}

	int ans = -1;
	for (int n = 1; n <= N; ++n) {
		vector<bool> sports(M, true);
		vector<int> join(N, 0);
		while (true) {
			bool ok = true;
			vector<int> cnt(M, 0);
			for (int i = 0; i < N; ++i) {
				while (join[i] <= M) {
					if (join[i] == M) {
						ok = false;
						break;
					}
					if (sports[ a[i][join[i]] ]) {
						++cnt[ a[i][join[i]] ];
						break;
					}
					++join[i];
				}
			}
			if (!ok) { break; }
			for (int i = 0; i < M; ++i) {
				if (cnt[i] > n) {
					ok = false;
					sports[i] = false;
				}
			}
			if (ok) {
				ans = n;
				break;
			}
		}
		if (ans > 0) { break; }
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin>>n;
    vector<bool> p(n+1,1);
    vector<ll> ar(n+1,1);
    p[0]=p[1]=0;
    for(ll i=2;i<=n;++i){
        if(p[i]){
            for(ll j=i+i;j<=n;j+=i){
                p[j]=0;
            }
        }
    }
    ll ans=0;
    for(ll i=2;i<=n;++i){
        if(p[i]){
            for(ll j=i;j<=n;j+=i){
                ll count=1;
                ll ch=j;
                while(ch%i==0){
                    ++count;
                    ch/=i;
                }
                ar[j]*=count;
            }
        }
    }
    for(ll i=1;i<=n;++i){
        ar[i]=ar[i]*i;
        ans+=ar[i];
    }
    cout<<ans<<endl;

    return (0);
}


Measured memory_bytes: 82664
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll, ll> P;

int main() {
    cin>>A>>B>>M;
    vec a(A), b(B);
    rep(i,A) cin>>a[i];
    rep(i,B) cin>>b[i];
    int ma = *min_element(ALL(a)), mb = *min_element(ALL(b));
    ll ans = ma + mb;
    rep(i,M){
        cin>>A>>B>>K;
        ans = min(ans, a[A - 1] + b[B - 1] - K);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

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

ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll mod = 1e9+7;

int main(){
    ll a, b;
    cin >> a >> b;
    
    ll result = 0;
    ll count = 1;
    while(count < b){
        result ++;
        count --;
        
        count += a;
    }
    
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
n = len(s)

A = [i%2 for i in range(n)]
B = [(i+1)%2 for i in range(n)]

ans0 = 0
ans1 = 0

for i in range(n):
    if int(s[i]) != A[i]:
        ans0 += 1
    if int(s[i]) != B[i]:
        ans1 += 1

print(min(ans0, ans1))


Measured memory_bytes: 4724
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a,b,c;
		a=sc.nextInt();
		b=sc.nextInt();
		c=sc.nextInt();
		if(a<b){
			if(b<c){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}else{
			System.out.println("No");
		}
		sc.close();
	}
}



Measured memory_bytes: 26240
#include <stdio.h>
#include <math.h>
int main(){
  double x1, y1, x2, y2;
  scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
  x1=x1-x2;
  x1=x1*x1;
  y1=y1-y2;
  y1=y1*y1;
  printf("%lf\n", sqrt(x1+y1));
  return 0;
}



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

struct hoseki{
  int kati,cost;
}r[20];
int main(void){
  int N,sum=0;
  cin>>N;
  for(int i=0;i<N;i++)cin>>r[i].kati; 
  for(int t=0;t<N;t++)cin>>r[t].cost;
  
  int a[20];
  for(int j=0;j<N;j++)a[j]=r[j].kati-r[j].cost;
  for(int k=0;k<N;k++)if(a[k]>0)sum+=a[k];
  cout<<sum;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(void){
    int n,x;
    int sum=0;
    while(1){
       cin>>n>>x;
       if(n == 0&&x == 0){
            break;
        }
        sum=0;
        for(int i = 1; i <= n-2; i++){
            for(int j = i + 1; j <= n - 1; j++){
                for(int k = j + 1; k <= n; k++){
                    if((i+j+k) == x){
                        sum++;
                    }
                }
            }
        }
        cout<<sum<<endl;
        }
    return 0;
}


Measured memory_bytes: 3100
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var set = new HashSet<int>();
            for (int i = 1; i < 10; i++)
            {
                for (int j = i; j < 10; j++)
                {
                    set.Add(i * j);
                }
            }

            var ans = set.Contains(int.Parse(Console.ReadLine())) ? "Yes" : "No";
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

int c=0;string s;cin>>s;
for(int i=0;i<4;i++)
{
	if(s[i]=='+') c++;
	else c--;
}
cout<<c;


return 0;
}


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


long long N, x[100000], L;
int nx[100000][20];
int Q;


int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    cin >> L;


    // dist [l, r] <= L
    int r = 0;
    for(int l = 0; l < N; l++){
        while(r+1 < N && x[r+1] - x[l] <= L){
            r++;
        }
        nx[l][0] = r;
    }
    for(int i = 0; i < N; i++){
        //cout << nx[i][0] << endl;
    }

    for(int k = 1; k < 20; k++){
        for(int i = 0; i < N; i++){
            nx[i][k] = nx[nx[i][k-1]][k-1];
        }
    }
    for(int k = 0; k < 20; k++){
        for(int i = 0; i < N; i++){
            //cout << nx[i][k] << " ";
        }
        //cout << endl;
    }
        

    
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(a > b){
            int tmp = a;
            a = b;
            b = tmp;
        }
        int ans1, k1;
        if(a == b){
            cout << 0 << endl;
            continue;
        }
        // not begin, but end
        int begin = 0, end = 100001;
        while(end - begin > 1){
            int mid = (begin + end) / 2;
            int goal = a;
            for(int k = 0; k < 20; k++){
                if( (1 << k) & mid ){
                    goal = nx[goal][k];
                }
            }
            if(goal >= b){
                end = mid;
            }else{
                begin = mid;
            }
        }
        cout << end << endl;;

    }
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main()
{
	string S;
	cin >> S;
	ll S_size = S.size();
	ll W_counter = 0;
	ll osero_counter = 0;

	for (size_t i = 0; i < S_size; i++)
	{

		if (S[S_size - 1 - i] == 'B')
		{
			osero_counter += W_counter;
		}
		else if (S[S_size - 1 - i] == 'W')
		{
			W_counter++;
		}
	}
	cout << osero_counter << endl;
	return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())

if K == 0:
    print(N ** 2)
else:
    ans = 0
    for b in range(K + 1, N + 1):
        n_groups = N // b
        rest = N % b
        ans += n_groups * (b - K) + max(0, rest - K + 1)

    print(ans)


Measured memory_bytes: 2940
h,w,a,b = map(int,input().split())
ans = [[0]*w for i in range(h)]
fl = True

for i in range(a):
    for j in range(b):
        ans[j][i] = 1
        
for i in range(w-a):
    for j in range(h-b):
        ans[b+j][a+i] = 1
        
for i in range(h):
    print(*ans[i],sep = "")

Measured memory_bytes: 78300
#include "bits/stdc++.h"
using namespace std;
#define REP(m,n) for(int i=m;i<n;i++)
#define REPj(m,n) for(int j=m;j<n;j++)
#define MOD 1000000007
#define INF 10000000000000000
#define ll long long
#define mp make_pair

vector<bool>v;
vector<int>l;

int main(){
	string s;
	cin>>s;
	for(int i=0;i<(int)(s.size());i+=2){
		cout<<s[i];
	}
	cout<<endl;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
  int n;
  cin >> n;
  
  int *h = new int[n];
  for (int i = 0; i < n; i++)
    cin >> h[i];
  
  int sum = 1;
  for (int i = 1; i < n; i++) {
    bool flag = true;
    for (int j = 0; j < i; j++) {
      if (h[j] > h[i]) {
        flag = false;
        break;
      }
    }
    if (flag)
      sum++;
  }
  cout << sum << endl;
  
  delete h;
  
  return 0;
}

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

using namespace std;

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

int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  REP(i, n){
    v[i] = i + 1;
  }
  vector<int> a(n);
  int x = 0;
  REP(i, n) cin >> a[i];
  do{
    if(a == v) break;
    ++x;
  }while(next_permutation(v.begin(), v.end()));
  REP(i, n){
    v[i] = i + 1;
  }
  vector<int> b(n);
  int y = 0;
  REP(i, n) cin >> b[i];
  do{
    if(b == v) break;
    ++y;
  }while(next_permutation(v.begin(), v.end()));
  cout << abs(x - y) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>

using namespace std;

int main(void){
  string s;
  cin >> s;
  for(int i = 0; i < s.length(); i += 2) cout << s[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 512
n = int(input())
mod = 10 ** 9 + 7


def table():
    k = 10 ** 6 + 5  # 変える
    fac = [1] * k
    finv = [1] * k
    inv = [0] * k
    inv[1] = 1
    for i in range(2, k):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod
    return fac, finv


fac, finv = table()


def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


ans = 0
for i in range(2, n + 1):
    ans += comb(n, i) * (pow(2, i, mod) - 2) * pow(8, n - i, mod) % mod

print(ans % mod)


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

#define ll long long
#define ld long double
#define MOD (1000000000+7)
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll x,a,b;
    cin >> x >> a >> b;
    if (x+a < b)
    {
        cout << "dangerous" << endl;
        return 0;
    }
    if (b <= a)
    {
        cout << "delicious" << endl;
        return 0;
    }
    cout << "safe" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  ll day = 10;
//  vector<vector<ll>> fs(N, vector<ll>(day));
  vector<ll> fs(N);
  vector<vector<ll>> cs(N, vector<ll>(day));
  for (auto i = 0; i < N; i++) {
    ll bits = 0;
    for (auto j = 0; j < day; j++) {
      ll x;
      cin >> x;
      bits = (bits << 1) + x;
    }
    fs[i] = bits;
  }
  for (auto j = 0; j < N; j++) {
    for (auto k = 0; k < day + 1; k++) {
      cin >> cs[j][k];
    }
  }

  ll res = - tenq * 1000;
  for (auto x = 1; x < 1 << day; x++) {
    ll total = 0;
    for (auto i = 0; i < N; i++) {
      ll count = 0;
      ll y = fs[i] & x;
      while (y > 0) {
        if (y % 2 == 1) count++;
        y /= 2;
      }
//      cout << "fs[" << i << "]=" << fs[i]
//           << " x=" << x
//           << " y=" << (fs[i] & x)
//           << " count=" << count
//           << " cost=" << cs[i][count] << endl;
      total += cs[i][count];
    }
    if (res < total) res = total;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;

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


Measured memory_bytes: 4832
#include <cstdio>
#include <algorithm>
#include <set>
#include <utility>
static const int MAXN = 1e5 + 4;
static const int INF = 0x3fffffff;

int n;
int x[MAXN], y[MAXN];
int p[MAXN];

namespace dsu {
    int p[MAXN];
    inline void init(int n) { for (int i = 0; i < n; ++i) p[i] = i; }
    inline int root(int u) { return (p[u] == u) ? u : (p[u] = root(p[u])); }
    inline void merge(int u, int v) { u = root(u), v = root(v); p[u] = v; }
}

struct seg {
    int diff, u, v;
    seg() { }
    seg(int diff, int u, int v) : diff(diff), u(u), v(v) { }
    inline bool operator < (const seg &other) const { return diff < other.diff; }
};

std::multiset<seg> sx, sy;

inline bool x_cmp(int a, int b) { return x[a] < x[b]; }
inline bool y_cmp(int a, int b) { return y[a] < y[b]; }

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%d%d", &x[i], &y[i]);

    for (int i = 0; i < n; ++i) p[i] = i;
    std::sort(p, p + n, x_cmp);
    for (int i = 0; i < n - 1; ++i) sx.insert(seg(x[p[i + 1]] - x[p[i]], p[i + 1], p[i]));
    std::sort(p, p + n, y_cmp);
    for (int i = 0; i < n - 1; ++i) sy.insert(seg(y[p[i + 1]] - y[p[i]], p[i + 1], p[i]));

    long long ans = 0;
    dsu::init(n);
    for (int i = 0; i < n - 1; ++i) {
        seg tx, ty;
        while (!sx.empty()) {
            tx = *sx.begin();
            if (dsu::root(tx.u) == dsu::root(tx.v)) sx.erase(sx.begin());
            else break;
        }
        if (sx.empty()) tx = seg(INF, 0, 0);
        while (!sy.empty()) {
            ty = *sy.begin();
            if (dsu::root(ty.u) == dsu::root(ty.v)) sy.erase(sy.begin());
            else break;
        }
        if (sy.empty()) ty = seg(INF, 0, 0);

        if (tx < ty) {
            dsu::merge(tx.u, tx.v);
            ans += tx.diff;
            sx.erase(sx.begin());
        } else {
            dsu::merge(ty.u, ty.v);
            ans += ty.diff;
            sy.erase(sy.begin());
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
//
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mx 100010
#define pi acos(-1)
#define endl '\n'
#define Fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
//
int main()
{
    ll n, a, b, i, count = 0, res = 0;

    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> a >> b;
        if (a == b)
        {
            count++;
            if (count == 3)
            {
                res = 1;
                count = 0;
            }
        }
        else
        {
            count = 0;
        }
    }
    if (res == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

ta, tb = 0, sum(B)
ptr = M
ans = 0
for i in range(N+1):
    while ptr > 0 and ta + tb > K:
        ptr -= 1
        tb -= B[ptr]
    if ta + tb <= K:
        ans = max(ans, i + ptr)
    if i < N:
        ta += A[i]
print(ans)


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

int main(){
  int a, N, colour[9] = {}, ans = 0;
  cin >> N;
  
  for (int i = 0; i < N; i++){
    cin >> a;
    colour[min(a/400, 8)]++;
  }
  
  for (int i = 0; i < 8; i++){
    if (colour[i] > 0){
      ans += 1;
    }
  }
  
  cout << max(ans, 1) << " " << ans+colour[8] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
	int a,b;
	cin>>a>>b;
	if(a<=0&&0<=b)cout<<"Zero"<<endl;
	else if(1<=a)cout<<"Positive"<<endl;
	else{
		int t=abs(b-a);
		if(t%2==0)cout<<"Negative"<<endl;
		else cout<<"Positive"<<endl;
	}
}

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

// THINK: INT vs LONG LONG?

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

    string s;
    cin >> s;
    ll sum = 0;
    for (auto c: s){
        sum += (c - '0');
    }
    cout << (sum % 9 ? "No" : "Yes");
    return 0;
}

Measured memory_bytes: 3740
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n,m=MI()
picla=[]
picsm=[]
for i in range(n):
    picla.append(input().rstrip())
for i in range(m):
    picsm.append(input().rstrip())
for i in range(n-m+1):
    for j in range(n-m+1):
        count=0
        for k in range(m):
            '''print(picla[i+k][j:j+m],end=" ")
            print(picsm[k])'''
            if picla[i+k][j:j+m]==picsm[k]:
                count+=1
        if count==m:
            print("Yes")
            sys.exit()
print("No")


Measured memory_bytes: 3316
#include <iostream>

using namespace std;

int main(){
	
	int m,d;
	cin>>m>>d;
	int d1,d10;
	int res =0;
	for(int i=22;i<=d;i++){
		d1 = i%10;
		d10=i/10;
		if(d10>=2&&d1>=2&&d1*d10<=m)res++;
	}
	cout<<res<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <fstream>
#include <cassert>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;



int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	string s;
	cin >> n >> s;
	s += "KEK";
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')ans++;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,d,x;
    cin >> n >> d >> x;
    int ans = 0;
    for(int i = 0;i < n;i++)
    {
        int a;
        cin >> a;
        ans += (d - 1) / a + 1;
    }
    cout << ans + x;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

for line in sys.stdin:
    c1, c2, c3 = map(int, line.split())
    mysum = c1+c2
    count = 0
    for i in range(1, 11):
        if i == c1 or i == c2 or i == c3:
            continue
        if mysum + i <= 20:
            count += 1
    if count > 3:
        print "YES"
    else:
        print "NO"

Measured memory_bytes: 6416
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
balls = [[1, 0] for _ in range(N)]  # white, red
balls[0] = [0, 1]

for _ in range(M):
	x, y = MAP()

	w_x, r_x = balls[x-1]
	w_y, r_y = balls[y-1]
	
	if w_x >= 1 and r_x >= 1:
		balls[x-1][0] -= 1
		balls[y-1][1] += 1
	elif w_x == 0:
		balls[x-1][1] -= 1
		balls[y-1][1] += 1
	else:
		balls[x-1][0] -= 1
		balls[y-1][0] += 1

ans = 0
for i in range(N):
	if balls[i][1]:
		ans += 1
print(ans)


Measured memory_bytes: 15316
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    N, K = MAP()
    H = LIST()

    cnt = 0
    for h in H:
        if h >= K: cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

Measured memory_bytes: 51440
from math import log2, ceil

N, K = map(int, input().split())
ans = 0
max_pow = ceil(log2(K))
for n in range(1, N + 1):
    ans += 2 ** (max_pow - max(0, ceil(log2(K / n))))
print(ans / (N * 2 ** max_pow))

Measured memory_bytes: 3188
#pragma warning(disable:4996)

#include<iostream>
#include<algorithm>
//#include<unordered_map>
#include<fstream>
#include<iomanip>
#include<string>
#include<cmath>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<sstream>
#include<cstdio>
#include<ctime>
#include<cstdlib>
#define INF 0x3f3f3f3f
#define inf 0x7FFFFFFF
#define MOD 2147493647
#define moD 1000000003
#define pii pair<int,int>
#define eps 1e-7
#define equals(a,b) (fabs(a-b)<eps)
#define bug puts("bug")
#define re  register
#define fi first
#define se second
const int maxn = 1e3 + 5;
const double Inf = 10000.0;
const double PI = acos(-1.0);
typedef  long long ll;
using namespace std;

int main() {
	int n;
	string ss;
	int cnt1, cnt2, cnt3, cnt4;
	cnt1 = cnt2 = cnt3 = 0;
	cnt4 = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ss;
		if (ss == "AC") cnt1++;
		else if (ss == "WA") cnt2++;
		else if (ss == "TLE") cnt3++;
		else cnt4++;
	}
	printf("AC x %d\n", cnt1);
	printf("WA x %d\n", cnt2);
	printf("TLE x %d\n", cnt3);
	printf("RE x %d\n", cnt4);
}

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

int main(){
	int M, K; cin >> M >> K;
	int N = pow(2,M);
	
	if( M == 0 && K == 0){
		cout << 0 << " " << 0 << " " << endl;
		return 0;
	}
	
	if( M == 1 ){
		if(  K == 0 ){
			cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
			return 0;
		}
		if( K == 1 ){
			cout << -1 << endl;
			return 0;
		}
	}
	
	
	if( N <= K ){
		cout << -1 << endl;
		return 0;
	}
	
	
	
	for( int i = 0; i < N; i++ ){
		if( i != K )
		cout << i << " ";
	}
	cout << K << " ";
	for( int i = N - 1; i >= 0; i-- ){
		if( i != K )
		cout << i << " ";
	}
	cout << K << endl;
}

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

void solve(long long N)
{
    long long S = 1000;
    while (S < N)
    {
        S += 1000;
    }
    cout << S - N << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3760
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

from math import cos, sin, radians

a,b,h,m = (int(x) for x in input().split())
t1 = radians(((h%12) * 30) + m*0.5)
t2 = radians(((m%60) * 6))

x1 = -a*sin(-t1)
y1 = a*cos(-t1)
x2 = -b*sin(-t2)
y2 = b*cos(-t2)
print(((x2-x1)**2+(y2-y1)**2)**0.5)


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

int main(){
	int m,d;
	cin >> m >> d;
	int cnt = 0;
	for(int i=1;i<=m;i++) {
		for(int j=1;j<=d;j++) {
			int a = j/10;
			int b = j%10;
			if(a<2 || b <2) continue;
			if(i == a*b) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }

void solve() {
	int n; cin >> n;
    vector<int> a(3 * n);
    rep(i, 3 * n) {
        cin >> a[i];
    }
    sort(all(a));
    int ans = 0, cnt = 0, i = 3 * n - 2;
    while(cnt < n) {
        cnt ++;
        ans += a[i];
        i -= 2;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 2688
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		String[] s = new String[n];
		for(int i = 0;i < n;i++){
			s[i] = saori.nextHayami();
		}
		int ans = 0;
		boolean pflg = true;
		boolean wflg = true;
		boolean gflg = true;
		boolean yflg = true;
		for(int i = 0;i < n;i++){
			if(s[i].equals("P") && pflg){
				ans++;
				pflg = false;
			}
			if(s[i].equals("W") && wflg){
				ans++;
				wflg = false;
			}
			if(s[i].equals("G") && gflg){
				ans++;
				gflg = false;
			}
			if(s[i].equals("Y") && yflg){
				ans++;
				yflg = false;
			}
		}
		if(ans == 3){
			System.out.println("Three");
		} else {
			System.out.println("Four");
		}
		saori.close();
    }
}

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

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

int main(){
	int N;
	cin >> N;
	int F[N] = {0}, P[N][11];
	int ans = -1000000007;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < 10; j++){
			int tmp;
			cin >> tmp;
			if(tmp)
				F[i] |= (1<<j);
		}
	}
	for(int i = 0; i < N; i++){
		for(int j = 0; j < 11; j++){
			cin >> P[i][j];
		}
	}

	for(int bit = 1; bit < (1<<10); bit++){
		int pro = 0;
		for(int i = 0; i < N; i++){
			int c = __builtin_popcount(bit & F[i]);
			pro += P[i][c];
		}
		ans = max(ans,pro);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256