akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

// g++ -std=c++11 -O2 -Wall *.cpp -o *
#define eps 1e-9
#define MAX 10000010
#define MOD 1000000007
#define INF 1e9+10
#define PI 3.14159265358979323846
#define Fi first
#define Se second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define maxof(a) *max_element(all(a))
#define minof(a) *min_element(all(a))
typedef long long ll;
typedef pair<int, int> pairs;


int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// freopen("input.txt", "r", stdin);
	// freopen("output.out", "w", stdout);

	int n;
	cin >> n;
	int m = ceil((2000-n)*1.0 / 200);
	cout << m << "\n";

	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
int n, a, b;
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> a >> b;
	int mx = min(a, b), mn = inf;
	fw (p, 0, n + 1) {
		if (a + b >= n - p) {
			mn = min(mn, a + b - n + p);
		}
	}
	cout << mx << " " << mn;
	return 0;
}

Measured memory_bytes: 256
import math
A,B,C,D = map(int,input().split())
count1 = 0
count2 = 0
ans1 = B-B//C-B//D+B//((C*D)//math.gcd(C,D))
A = A-1
ans2 = A-A//C-A//D+A//((C*D)//math.gcd(C,D))
print(ans1-ans2)

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

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

    int a;
    int odd = 0, even = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a % 2 == 0) {
            even++;
        } else {
            odd++;
        }
    }

    cout << (odd % 2 ? "NO" : "YES") << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
     
     
#define fs first
#define sc second
     
using namespace std;
     
     
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1000000007;
ll fact[200200];
ll invfact[200200];
 
inline ll take_mod(ll a){
    return (a % mod + mod) % mod;
}
 
inline ll add(ll a, ll b){
    return take_mod(a+b);
}
 
inline ll sub(ll a, ll b){
    return take_mod(a-b);
}
 
 
inline ll mul(ll a, ll b){
    return take_mod(a * b);
}
 
inline ll pow(ll x, ll n){
    ll res = 1LL;
    while(n > 0){
        if(n & 1) res = mul(res, x);
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}
 
ll mod_inv(ll x){
    return pow(x, mod-2);
}
 
void make_fact(ll n){
    fact[0] = 1;
    ll res = 1;
    for(int i = 1; i <= n; i++){
        fact[i] = res;
        res = mul(res, i+1);
    }
}
 
void make_invfact(ll n){
    invfact[0] = 1;
    invfact[n] = mod_inv(fact[n]);
    for(int i = n-1; i >= 1; i--){
        invfact[i] = mul(invfact[i + 1], i + 1);
    }
}
 
ll perm(ll n, ll k){
    return mul(fact[n], invfact[n-k]);
}
 
ll comb(ll n, ll k){
  return mul(mul(fact[n], invfact[n-k]), invfact[k]);
}
     
int main(){
  ll N, K;

  cin >> N >> K;

#ifdef DEBUG
  cout << "N=" << N << ", K=" << K << endl;
#endif

  make_fact(4000);
  make_invfact(4000);  

  for(ll i = 1; i <= K; ++i){
    ll bbnum = K - i;
    ll bsnum = i - 1;
    ll rbnum = N - K - i + 1;
    ll rsnum = i;

    // cout << "b i=" << i << endl;
    // cout << bbnum << endl;
    // cout << bsnum << endl;
    // cout << comb(bbnum + bsnum, bsnum) << endl;
    // cout << "r i=" << i << endl;
    // cout << rbnum << endl;
    // cout << rsnum << endl;
    // cout << comb(rbnum + rsnum, rsnum) << endl;
    if(rbnum >=0 ){
      cout << mul(comb(bbnum + bsnum, bsnum), comb(rbnum + rsnum, rsnum)) << endl;
    } else {
      cout << 0 << endl;
    }
  }
  
  
  return 0;
}


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

const int MOD = 1e9 + 7;

char mat[3][60];

int dp[60][3][3];

int main( void ) {
    
    int n;
    cin >> n;
    cin >> (mat[1] + 1) >> (mat[2] + 1);
    
    int st;
    if (mat[1][1] == mat[2][1]) {
        dp[1][0][0] = dp[1][1][1] = dp[1][2][2] = 1;
        st = 2;
    }
    else {
        dp[2][0][1] = dp[2][0][2] = dp[2][1][0] = dp[2][1][2] = dp[2][2][0] = dp[2][2][1] = 1;
        st = 3;
    }
    
    for (int i = st; i <= n; ++i) {
        if (mat[1][i] == mat[1][i + 1])
            continue;
        
        if (mat[1][i] == mat[2][i]) {
            for (int k = 0; k <= 2; ++k) {
                for (int p1 = 0; p1 <= 2; ++p1)
                for (int p2 = 0; p2 <= 2; ++p2)
                    if (k != p1 && k != p2)
                        dp[i][k][k] = (dp[i][k][k] + dp[i - 1][p1][p2]) % MOD;
            }
        } else {
            for (int p1 = 0; p1 <= 2; ++p1)
            for (int p2 = 0; p2 <= 2; ++p2)
            for (int q1 = 0; q1 <= 2; ++q1)
            for (int q2 = 0; q2 <= 2; ++q2)
                if (p1 != p2 && p1 != q1 && p2 != q2)
                    dp[i][p1][p2] = (dp[i][p1][p2] + dp[i - 2][q1][q2]) % MOD;
        }
    }
    
    int ans = 0;
    for (int p1 = 0; p1 <= 2; ++p1)
    for (int p2 = 0; p2 <= 2; ++p2)
        ans = (ans + dp[n][p1][p2]) % MOD;
    
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

double L;

int main() {
    cin >> L;
    cout << fixed << setprecision(6) << pow(L / 3, 3);
}

Measured memory_bytes: 4136
//#define _CRT_SECURE_NO_WARNINGS
//#include <bits/stdc++.h>
#include "bits/stdc++.h"

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

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k; cin >> n >> k;
	vector<int> a(n);
	vector<int> isvisit(n,0);
	int x = 0;
	rep(i, n) {
		cin >> a[i];
		a[i]--;
	}
	int cnt = 0;
	while (k > 0) {
		cnt++;
		k--;
		x = a[x];
		if (isvisit[x] == 0) {
			isvisit[x] = cnt;
		}
		else {
			k = k % (cnt - isvisit[x]);
		}
	}
	cout << x + 1 << endl;

}


Measured memory_bytes: 6368
data = []
for x in range(0,3*10*4):
    data.append(0)
num = int(input())
for x in range(0,num):
    b,f,r,v = map(int, input().split())
    tmp = data.pop(30*(b-1)+10*(f-1)+(r-1))
    data.insert(30*(b-1)+10*(f-1)+(r-1),v+tmp)
for x in range(0,4) :
    for y in range(0,3):
        for z in range(0,10):
            print('',data.pop(0),end='')
        print("")
    if x != 3:
        print("####################")
    else:
        pass


Measured memory_bytes: 7752
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(), v.end()
#define fori(i, j, k) for (int i = (j); i < (int)(k); i++)
#define forb(i, j, k) for (int i = (j); i >= (int)k; i--)
#define lchild(ind) 2 * ind + 1
#define rchild(ind) 2 * ind + 2
#define bug(val) cout << "# " << val << endl;
#define bugs(val) cout << '_' << val;
#define bugl(val) cout << "## " << val << endl;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
typedef pair<ll, pll> plp;
typedef pair<pll, int> ppi;
typedef pair<pll, ll> ppl;
typedef pair<pll, pll> ppp;
typedef vector<int> vi;
typedef vector<ll> vll;

const int maxn = 1e6 + 1;
const ll inf = 2e18, mod = 1e9 + 7;

int n, a[maxn];
ll ans;
map<ll, int> cnt;

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

	cin >> n;
	fori (i, 0, n)
		cin >> a[i];
	ll sum = 0;
	cnt[sum]++;
	fori (i, 0, n)
	{
		sum += a[i];
		ans += cnt[sum];
		cnt[sum]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 13568
x1, y1, x2, y2 = list(map(int, input().split()))

diff_x = x2-x1
diff_y = y2-y1
x3 = x2-diff_y
y3 = y2+diff_x
x4 = x3-diff_x
y4 = y3-diff_y

print(x3, y3, x4, y4)


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>
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 INF 10000000000000000
#define ll long long
#define mp make_pair

vector<pair<ll, ll>>edge[200000];
vector<ll>cost(200000);

int main() {
	int n;
	cin >> n;
	queue<int>que;
	REP(0, n - 1) {
		ll a, b, c;
		cin >> a >> b >> c;
		edge[a].push_back(mp(b, c));
		edge[b].push_back(mp(a, c));
	}
	int q, k;
	cin >> q >> k;
	REP(0, n + 1) {
		cost[i] = INF;
	}
	cost[k] = 0;
	que.push(k);
	while (que.empty() == false) {
		int a = que.front();
		que.pop();
		REP(0, edge[a].size()) {
			if (cost[edge[a][i].first] > cost[a] + edge[a][i].second) {
				cost[edge[a][i].first] = cost[a] + edge[a][i].second;
				que.push(edge[a][i].first);
			}
		}
	}
	REP(0, q) {
		ll a, b, ans;
		cin >> a >> b;
		ans = cost[a] + cost[b];
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
  int A,B,C,X,Y;
  cin>>A>>B>>C>>X>>Y;
  long int minp=A*X+B*Y;
  for(int c=2;c<=max(2*X,2*Y);c+=2){
    long int p=A*max(0,(X-c/2))+B*max(0,(Y-c/2))+C*c;
    minp=min(minp,p);
  }
  cout<<minp<<endl;
}


Measured memory_bytes: 256
#define STOPIT
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
	do {\
		std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
		debug_impl(__VA_ARGS__);\
		std::cerr << std::noboolalpha;\
	} while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
	{ for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
	for (auto it = v.begin(); it != v.end(); it++)
		{os << (it != v.begin() ? "," : "") << *it;}
	return os << "}";
}

template <typename T>
auto make_vector_impl(size_t sz, T t) {return std::vector<T>(sz, t);}

template <size_t N, typename T, typename U, std::enable_if_t<N == 1, std::nullptr_t> = nullptr>
auto make_vector(size_t sz, U u) {return make_vector_impl(sz, T(u));}

template <size_t N, typename T, std::enable_if_t<N == 1, std::nullptr_t> = nullptr>
auto make_vector(size_t sz) {return std::vector<T>(sz);}

template <size_t N, typename T, typename... Args, std::enable_if_t<N != 1, std::nullptr_t> = nullptr>
auto make_vector(size_t a, Args... args) {return make_vector_impl(a, make_vector<N - 1, T>(args...));}

template <typename T, typename Size_t>
auto& at(T& t, Size_t i) {return t.at(i);}

template <typename T, typename Size_t, typename... Args>
auto& at(T& t, Size_t i, Args... args) {return at(t.at(i), args...);}

int main() {
	std::cin.tie(0); std::cin.sync_with_stdio(false);
	int h, w, n;
	std::cin >> h >> w >> n;
	std::vector<int> a(n); std::cin>>a;
	std::vector<int> b;
	rep(i,0,n) {
	  loop(a.at(i))	b.emplace_back(i);
	}
	debug(b);

	auto ans = make_vector<2,int>(h,w);
	rep(i,0,h) rep(j,0,w) {
		at(ans,i,j) = b.at(i*w + (i%2==0 ? j : w-1-j));
	}
	debug(ans);

	for (auto& v : ans) for (int & x : v) x++;
	for (auto& v : ans) {
		rep(j,0,w) {
			std::cout << (0 < j ? " " : "") << v.at(j);
		}
		std::cout << std::endl;
	}
	return 0;
}

Measured memory_bytes: 512
def main():
	def Technique_often_used():    
		# enumerate: for i, a in enumerate(a_list):
		# q, mod = divmod(a, b)
		# Functional Programming: filter, map, reduce
		pass
	def naming_conventions():
		# [s_1, s_2, s_3, ..., s_k] is named s_k
		# [[s_11, s_12, ..., s_1k], ..,[s_j1, s_j2, ..., s_jk] is named s_jk
		# [[b1,c1],[b2,c2],..,[bm,cm]] is named bc
		# if there is something strange in a list then I add _ to the list's name (ex:s_jk_)
		pass
	def visual_studio_code_shortcut():    
		# visual studio code shortcut https://qiita.com/TakahiRoyte/items/cdab6fca64da386a690b
		# delete line: Ctrl+Shift+k
		# choose same words: Ctrl+Shift+l
		pass
	import sys
	from itertools import combinations, permutations # https://docs.python.org/ja/3/library/itertools.html
	from collections import deque, Counter # https://docs.python.org/ja/3/library/collections.html#collections.deque
	from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html
	from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
	from functools import reduce
	from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
	def gcds(numbers):
		return reduce(gcd, numbers)
	def lcm(x, y):
		return (x * y) // gcd(x, y)
	def lcms(numbers): #
		return reduce(lcm, numbers, 1)

	# set the inputs
		# open(0).read() is a convenient method: 
		# ex) n, m, *x = map(int, open(0).read().split())
		#     min(x[::2]) - max(x[1::2])
		# ex2) *x, = map(int, open(0).read().split())
		#     don't forget to add comma after *x if only one variable is used
		# ex1) n, k = R()
		# ex2) v = list(R())
		# ex3) bc = [list(R()) for i in range(m)]

	R = lambda: map(int, input().split())
	q = int(input())
	queries = [list(R()) for i in range(q)]

	# q = 4
	# queries=[[1,4,2],[1,5,3],[1,-9,5],[1,1,-8],[2]]

	l = []
	r = []
	ans = 0
	for query in queries:
		if query[0] == 1:
			a = heappushpop(l,-query[1])
			b = heappushpop(r, query[1])
			heappush(l,-b)
			heappush(r,-a)
			ans += abs(b+a) + query[2]
		else:
			print(-l[0],ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 69764
#include<stdio.h>
#include<map>
#include<algorithm>
#include<string.h>
#include<vector>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<ctype.h>
using namespace std;

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

const int MM = 1000000007;
const int MX = 100005;

vector<int> T[MX];
int cnt[MX];
int N, K;

pii dfs(int x){
	pii r = pii(0, 0);
	for(int c : T[x]){
		pii t = dfs(c);
		if( t.second == K-1 && x != 1 ) t.second = 0, t.first++;
		else t.second++;
		r.first += t.first;
		r.second = max(r.second, t.second);
	}
	return r;
}

int main()
{
	scanf("%d%d", &N, &K);
	int ans = 0;
	for(int i = 1; i <= N; i++){
		int a;
		scanf("%d", &a);
		if( i == 1 ){
			if( a != 1 ) ans++;
		}
		else{
			T[a].push_back(i);
		}
	}
	ans += dfs(1).first;
	printf("%d\n", ans);
}


Measured memory_bytes: 11904
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define ul unsigned long long int
#define vi vector<int>
#define vl vector<int64_t>
#define all(x) x.begin(),x.end()
#define pb push_back
#define fo(x,a,b) for(int x=a; x<b; x++)
#define rfo(x,a,b) for(int x=a; x>=b; x--)
#define fi first
#define sec second
#define mp make_pair
int sgn(int x) { return x>0 ? 1 : ( x<0 ? -1 : 0); }
typedef pair<int,int> pairs;
double pi = 3.14159265358979323846;
ll mod = 1000000007;

void solve()
{
  ll n;
  cin>>n;
  if(n%2)
  {
    ll x=7;
    ll ans=1;
    bool good = false;
    while(ans<=n)
    {
      if(x%n==0)
      {
        cout<<ans<<"\n";
        good=true;
        break;
      }
      else x=x%n*10+7;
      ans++;
    }
    if(!good) cout<<-1<<"\n";
  }
  else cout<<-1<<"\n";
    cout<<"\n";
    return;
}
int main()
{
#ifdef _DEBUG
    freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll t;
    //cin>>t;
    //while(t--)
    {
        solve();
    }
    return 0;
}

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

int main() {
		int N, K, ans=0;
        cin >> N >> K;
  		vector<int> A(N);
        for (int i=0; i<N; i++){
          		cin >> A[i];
        }
  		sort (A.begin(), A.end());
        reverse (A.begin(), A.end());
        for (int i=0; i<K; i++){
          		ans += A[i];
        }
        cout << ans << endl;
}

Measured memory_bytes: 3588
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<stdlib.h>

int calDigNum(char*, int, int);
int main(void){
	char c[400], tmp[7];
	int i = 0, j = 0, dig_num = 1, stack[199], last;
	
	fgets(c, 399, stdin);
	while(c[i] != '\0'){
		if(isdigit(c[i])){
			dig_num = calDigNum(c, i+1, 1);
			strncpy(tmp, c+i, dig_num);
			tmp[dig_num] = '\0';
			i += dig_num-1;
			
			stack[j] = (int)strtol(tmp, NULL, 10);
			j++;
		}else{
			switch(c[i]){
				case '+':
				stack[j-2] += stack[j-1];
				break;
				case '-':
				stack[j-2] -= stack[j-1];
				break;
				case '*':
				stack[j-2] *= stack[j-1];
				break;
			}
			j--;
		}
		i += 2;
	}
	printf("%d\n", stack[0]);
	return 0;
}

int calDigNum(char* c, int i, int dig_num){
	if(isdigit(c[i])){
		return calDigNum(c, i+1, dig_num+1);
	}else{
		return dig_num;
	}
}


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

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner s = new Scanner(System.in);

		int[] a = new int[10];
		for(int i =0 ; i<10;i++){
			a[i] = s.nextInt();
			
		}
		Arrays.sort(a);
		System.out.println(a[9]);
		System.out.println(a[8]);
		System.out.println(a[7]);
		


	}

}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

#define MAX_N 100
int N;
int A[MAX_N];

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

	cin >> N;
	rep(i, 0, N) cin >> A[i];

	int max_v = 0;
	rep(i, 0, N) rep(j, i + 1, N) {
		max_v = max(max_v, abs(A[i] - A[j]));
	}
	cout << max_v << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof a)
#define rep(i, a, b) for(int i(a), i##_END_(b); i <= i##_END_; i++) 
#define drep(i, a, b) for(int i(a), i##_END_(b); i >= i##_END_; i--)
using namespace std;
template<class T> inline bool tomax(T &a, T b) {return a < b ? a = b, 1 : 0;}
template<class T> inline bool tomin(T &a, T b) {return b < a ? a = b, 1 : 0;}
typedef long long ll;
typedef double db;

const int N = 1e5 + 5;
int a[N], ans[N];


int main() {
    int n;
    scanf("%d", &n);
    rep(i, 1, n) scanf("%d", a + i);
    ll s = 0;
    rep(i, 1, n) s += a[i];
    for(int i = 2; i <= n; i += 2) s -= a[i] * 2;
    ans[1] = s;
    rep(i, 2, n) ans[i] = a[i - 1] * 2 - ans[i - 1];
    rep(i, 1, n) printf("%d%c", ans[i], " \n"[i == n]);
    return 0;
}


Measured memory_bytes: 2048
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class MainApp
{

	static public void Main()
	{

		int[] NM = Arrayint();
		int[] A = Arrayint();
		int vote = 0; 

		for(int i =0; i < NM[0]; i++)
		{
			vote += A[i];
		}

		vote = (vote-1) / (4 * NM[1]);
		int num = 0;

		for(int i = 0; i < NM[0]; i++)
		{
			if(A[i] > vote)
			{
				num++;
			}
		}

		string ans = "";

		if(num >= NM[1])
		{
			ans = "Yes";
		}
		else
		{
			ans = "No";
		}
		Console.WriteLine(ans);
	

	}


	private static string[] Arraystring()
	{
		return Console.ReadLine().Split(' ');
	}

	private static string Onestring()
	{
		return Console.ReadLine();
	}

	private static int Oneint()
	{
		return int.Parse(Console.ReadLine());
	}

	private static int[] Arrayint()
	{
		return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
	}
}

Measured memory_bytes: 13268
#include "iostream"
using namespace std;

long long int N, M, n = 1, m = 1, ans;
int main(){
	cin >> N>> M;
	if (abs(N - M) >= 2){
		ans = 0;
	}
	else{
		for (int i = 1; i <= N; i++){
			n = n*i;
			n = n % 1000000007;
		}
		for (int j = 1; j <= M; j++){
			m = m*j;
			m = m % 1000000007;
		}
		ans = n*m;
		ans = ans % 1000000007;
		if (N == M){
			ans = 2 * ans;
			ans = ans % 1000000007;
		}
	}
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000
#define INFTY 1000000000
 
struct Card{
   
  char suit;
  int value;
   
};
 
struct Card L[N], R[N];
 
void merge(struct Card *, int, int, int);
void mergeSort(struct Card *, int , int);
int partition(struct Card *, int, int);
void quickSort(struct Card *, int, int);
 
 
 
int main(){
   
  int n;
  int i;
  int v;
  struct Card A[N], B[N];
  char S[10];
  int stable;
 
  stable = 1;
   
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ) {
     
    scanf("%s %d", S, &v);
     
    A[i].suit = S[0];
    B[i].suit = S[0];
    A[i].value = v;
    B[i].value = v;
     
  }
 
  mergeSort(A, 0, n);
  quickSort(B, 0, n-1);
 
  for ( i = 0; i < n; i++ ){
    if ( A[i].suit != B[i].suit ) stable = 0;
  }
 
  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < n; i++ ) {
    printf("%c %d\n", B[i].suit, B[i].value);
  }
 
  return 0;
}
 
void merge(struct Card A[], int left, int mid, int right){
   
  int i, j, k;
  int n1;
  int n2;
   
  n1 = mid - left;
  n2 = right - mid;
 
  for ( i = 0; i < n1; i++ ) {
    L[i] = A[left + i];
  }
  for ( i = 0; i < n2; i++ ) {
    R[i] = A[mid + i];
  }
 
   
  L[n1].value = INFTY;
  R[n2].value = INFTY;
 
  i = 0;
  j = 0;
   
  for ( k = left; k < right; k++ ){
     
    if ( L[i].value <= R[j].value ){
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
  }
}
  
void mergeSort(struct Card A[], int left, int right ){
   
  int mid;
   
  if ( left + 1 < right ){
     
    mid = (left + right)/2;
     
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}
 
int partition(struct Card A[], int p, int r){
   
  int i, j;
  struct Card t, x;
 
  x = A[r];
  i = p - 1;
   
  for ( j = p; j < r; j++ ){
     
    if ( A[j].value <= x.value ){
       
      i++;
       
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
     
  }
   
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
   
  return i+1;
}
 
void quickSort(struct Card A[], int p, int r){
 
  int q;
   
  if ( p < r ){
     
    q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
     
  }
   
}

Measured memory_bytes: 2956
from collections import deque
def main():
    n, k = map(int, raw_input().split())
    s = raw_input().strip()
    ans = deque(list(s))
    if n == 1:
        if k % 2:
            print 'A' if s[0] == 'B' else 'B'
        else:
            print s[0]
        return
    f = True
    for i in xrange(400020):
        if i >= k:
            if f:
                print ''.join(list(ans))
            else:
                print ''.join('A' if x == 'B' else 'B' for x in ans)
            break
        if (ans[0] == 'A') == f:
            ans[0] = 'B' if f else 'A'
        else:
            f = not f
            ans.popleft()
            ans.append('A' if f else 'B')
    else:
        k -= 400020
        k %= 2
        if not f:
            ans = ['B' if x == 'A' else 'A' for x in ans]
            ans = deque(ans)
        if n % 2 and k:
            if ans[0] == 'A':
                ans[0] = 'B'
            else:
                ans[0] = 'A'
        print ''.join(ans)
main()


Measured memory_bytes: 6556
//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 998244353;
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}

vector<P>vec;
int n;
int main(){
ios::sync_with_stdio(false);
	cin>>n;
	rep(i, n){
		string s; cin >> s;
		int sum = 0, mn = 0;
		rep(j, s.size()){
			sum += (s[j]=='('?1:-1);
			chmin(mn, sum);
		}
		vec.pb(mp(sum, mn));
	}
	sort(all(vec), [&](const P &a, const P &b){
		if(a.fi >= 0 && b.fi < 0) return true;
		if(a.fi < 0 && b.fi >= 0) return false;
		if(a.fi >= 0 && b.fi >= 0){
			return a.sc > b.sc;
		}
		if(a.fi < 0 && b.fi < 0){
			return a.fi-a.sc > b.fi-b.sc;
		}
	});
	int cur = 0;
	rep(i, vec.size()){
		if(cur+vec[i].sc < 0){
			puts("No"); return 0;
		}
		cur += vec[i].fi;
	}
	if(cur != 0){
		puts("No"); return 0;
	}
	puts("Yes");}

Measured memory_bytes: 11620
S = input()
N = len(S)

if N == 1:
	print(S)
elif N == 2:
	print(9)
elif N == 3:
	A=int(S[0])
	B=int(S[1])
	C=int(S[2])
	print(((A-1)*100)+(B*10)+C+10)
elif N == 4:
	print(909)
elif N == 5:
	A=int(S[0])
	B=int(S[1])
	C=int(S[2])
	D=int(S[3])
	E=int(S[4])
	print(((A-1)*10000)+(B*1000)+(C*100)+(D*10)+E+910)
else:
	print(90909)


Measured memory_bytes: 3064
H,W,D = map(int, input().split())
A = {}
for i in range(H):
    for j, s in enumerate(input().split()):
        A[int(s)] = [i,j]
Q = int(input())
exam = []
for i in range(Q):
    exam.append(list(map(int, input().split())))

grid = [0]
manta = lambda x,y:abs(x[0]-y[0])+abs(x[1]-y[1])
for i in range(1, H*W+1):
    if (i-1) // D == 0:
        grid.append(0)
    else:
        grid.append(manta(A[i], A[i-D]) + grid[i-D])
for l,r in exam:
    print(grid[r]-grid[l])


Measured memory_bytes: 49724
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())


int main() {

	std::cin.tie(0);

	int k ;
	cin >> k;

	int v[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

	cout << v[k-1] << endl;



    return 0;
}


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

int main() {
  ll A, B, V, W, T;
  cin >> A >> V >> B >> W >> T;
  if( abs(A - B) <= (V - W) * T){
      cout << "YES" << endl;
  } else {
      cout << "NO" << endl;
  }
}

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

n = int(input())
p = []
m = dict()
for _ in range(n):
    r, c = map(int, input().split())
    p.append(r)
    if _ == n-1:
        p.append(c)

for i in range(n+1):
    m[(i,i)] = 0

for l in range(2, n + 1):
    for i in range(1, n - l + 2):
        j = i + l - 1
        m[(i, j)] = float('inf')
        #print(l,i,j)
        for k in range(i, j):
            value = m[(i, k)] + m[(k+1, j)] + p[i-1]*p[k]*p[j]
            m[(i, j)] = min(m[(i, j)], value)

print(m[(1, n)])

Measured memory_bytes: 6180
N = int(input())
A = list(map(int, input().split()))

A.sort()
mod = 10 ** 9 + 7
i = 0
res = 0
if N == 1:
  if A[0] == 0:
    print(1)
  else:
    print(0)
  exit(0)
if N % 2 == 1:
  res = 1
  i = 1
  if A[0] == A[1]:
    print(0)
    exit(0)
  if A[0] == 1:
    print(0)
    exit(0)
else:
  res = 2
  i = 2
  if A[0] != A[1]:
    print(0)
    exit(0)
  if A[0] == 0:
    print(0)
    exit(0)
while i < N - 1:
  if A[i] == A[i + 1]:
    if N % 2 == 0:
      if A[i] != 2 * (i / 2 + 1) - 1:
        res = 0
        break
    else:
      if A[i] != 2 * (i // 2 + 1):
        res = 0
        break
    res *= 2
    i += 2
  else:
    res = 0
    break
print(res % mod)

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


int main(){
  int n,k;
  cin>>n>>k;
  double prosum=0;

  for(int i=1;i<=n;i++){
    int point=i;
    double pro=1.0/n;
    while(point<=k-1){
      point*=2;
      pro/=2;
    }
    prosum+=pro;
  }
  cout <<fixed<<setprecision(13)<<prosum<<endl;

}





Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import sys
import math

x = input().split()
#y = input().split()


#y = int(input())
#x = int(input())
a = []
b = int(x[0])
num = int(x[1])
for i in range(b):
    a.append(int(input()))
a = sorted(a)
min = a[num-1]-a[0]
for i in range(num,b):
    if min > a[i]-a[i-num+1]:
        min = a[i]-a[i-num+1]
if min > a[b-1]-a[b-num]:
    min = a[b-1]-a[b-num]
print(min)


Measured memory_bytes: 10404
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint out[19];
map<pint,int> ma;
vector<pint> v;
int ne[7][7];
int main()
{
	int h,w,n,a,b;
	scanf("%d %d %d",&h,&w,&n);
	rep(i,n){
		scanf("%d %d",&a,&b);a--;b--;
		v.pb(mp(a,b));
	}
	sort(All(v));
	memset(out,0,sizeof(out));out[0]=(lint)(h-2)*(w-2);
	rep(i,n){
		int x=v[i].fi,y=v[i].se;
		memset(ne,0,sizeof(ne));
		rep(j,3) rep(k,5) ne[j][k]=ma[mp(x-2+j,y-2+k)];
		//cout<<x<<' '<<y<<endl;
		rep(j,3){
			//rep(k,5) cout<<ne[j][k]<<' ';cout<<endl;
		}
		rep(j,3) rep(k,3){
			int X=x-2+j,Y=y-2+k,co=0;
			if(X<0 || Y<0 || X+3>h || Y+3>w) continue;
			REP(l,j,3) REP(m,k,min(k+3,5)){
				co+=ne[l][m];
			}
			out[co]--;out[co+1]++;
		}
		ma[mp(x,y)]++;
		//rep(j,10) cout<<out[j]<<' ';cout<<endl;
	}
	rep(i,10) cout<<out[i]<<endl;
}


Measured memory_bytes: 94836
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 999999999999999999;
const ld pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++
int n, a[100000], b[100000], ans;
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	b[0] = a[0];
	for (int i = 1; i < n; i++)
		b[i] = b[i - 1] + a[i];
	for (int i = 0; i < n; i++) {
		int t = i, sum = b[i];
		while (t < n) {
			int k = lower_bound(a, a + n, sum*2) - a;
			if (a[k] > b[t] * 2)
				k--;
			if (k <= t)
				goto loop;
			t = k;
			sum = b[k];
		}
		ans++;
	loop:;
	}
	cout << ans << endl;
	getchar(); getchar();
}

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

int main()
{
    string s;
    cin >> s;
    int i,n,x=0;
    n=s.size();
    
    for(i=0;i<n/2;i++){
        if(s[i]!=s[n-i-1]){
            x++;
        }
    }
    for(i=0;i<n/4;i++){
        if(s[i]!=s[n/2-i-1]){
            x++;
        }
        if(s[n-1-i]!=s[i+n/2+1]){
            x++;
        }
    }
    if(x>0)
    cout << "No";
    else 
    cout << "Yes";
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
  // 整数の入力
  ll N,D;
  cin >> N;
  cin >> D;
  ll ans = 0;
  for(int i = 0; i < N;i++){
    ll a,b;
    cin >> a >> b;
    if (a*a + b*b <= D*D){
      ans++;
    }
  }
  cout << ans << endl;
 return 0;
}

Measured memory_bytes: 3620
def main():
    H, W = (int(_) for _ in input().split())
    INF = 10 ** 11

    def calc(h, w):
        # 縦に割る
        w1 = w // 2
        w2 = w - w1
        ret = INF
        for hh in range(1, h):
            ret = min(ret, max(w * hh, (h-hh)*w1, (h-hh)*w2) - min(w * hh, (h-hh)*w1, (h-hh)*w2))
        #横に割る
        for hh in range(1, h):
            h1 = (h-hh)//2
            h2 = h - hh - h1
            ret = min(ret, max(w*hh, w*h1, w*h2) - min(w*hh, w*h1, w*h2))
        return ret
    m1 = calc(H, W)
    m2 = calc(W, H)
    print(min(m1, m2))
    return
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int x = Integer.parseInt(scan.next());
        scan.close();

        int a = 0;
        int b = 0;

        for (long i = -5000; i <= 5000; i++) {
            for (long j = -5000; j <= 5000; j++) {
                long a5 = i * i * i * i * i;
                long b5 = j * j * j * j * j;
                if (a5 - b5 == x) {
                    a = (int)i;
                    b = (int)j;
                }
            }
        }

        System.out.println(a + " " + b);
    }
}


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

int main() {
  int N;
  cin>>N;
 	  	
  vector<int> vec(N);
      
  for(int i=0; i<N; i++)
    cin >> vec.at(i);
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int j,k;
  j=0,k=0;
  for (int i = 0; i < N; i++) {
    if(i%2==0)
      j+=vec.at(i);
    else
      k+=vec.at(i);
      }
  cout<<j-k<<endl;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    for(int i=0;i<a;i++){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	    for(int i=0;i<t;i++){ fact[i+1]=fact[i]*(i+1)%MOD;}
	fact_inv[t]=power(fact[t], MOD-2);
	for(int i=0;i<t;i++){ fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;}
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
	cin.tie(0);	ios::sync_with_stdio(false);

  int H,W,K; cin >> H >> W >> K;
  int i,j,all; all = 0;
  int ans=0;
  char c[H][W];
  bool p[H][W];
  rep(i,H){
      rep(j,W){
          cin >> c[i][j];
          if(c[i][j]=='#'){all++;}
          p[i][j]==false;
      }
  }

  for(int bit_H=0;bit_H<(1<<H);++bit_H){
      vector <int>S;
      rep(i,H){if(bit_H & (1<<i)){S.push_back(i);}}
      for(int bit_W=0;bit_W<(1<<W);++bit_W){
          vector <int>T;
          rep(j,W){if(bit_W & (1<<j)){T.push_back(j);}}
          int cnt=0;
          rep(i,S.size()){rep(j,W){if(c[S[i]][j]=='#'){cnt++;}}}
          rep(i,H){rep(j,T.size()){if(c[i][T[j]]=='#'){cnt++;}}}
          rep(i,S.size()){
              rep(j,T.size()){
                  if(c[S[i]][T[j]]=='#'){cnt--;}
              }
          }
          if(all-cnt==K){ans++;}
      }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define int long long int 
signed main() {
	string s,t;
    cin>>s;
    cin>>t;
    int flag=0;
    int n=s.size();
    int n1=t.size();
    for(int i=0;i<n;i++){
        if(s[i]!=t[i]){
            flag=1;
            break;
        }
    }
    if(flag==1){cout<<"No";}
    else if(n1==n+1){cout<<"Yes";}
    
	return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>

int main(){

	char S[3][101];
	int length[3], cursor[3];
	int turn = 0;
	char ch;

	int i;
	for(i=0; i<3; i++){
		scanf("%s", S[i]);
		length[i] = strlen(S[i]);
		cursor[i] = 0;
	}
	while(1){
		if(cursor[turn] == length[turn]){
			break;
		}
		
		ch = S[turn][cursor[turn]];
		cursor[turn] += 1;
		turn = ch - 'a';

	}

	printf("%c\n", turn+'A');	

	return 0;
}


Measured memory_bytes: 128
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(System.out);
        Task solver = new Task();
        int t = 1;
        while (t --> 0) solver.solve(1, scan, out);
        out.close();
    }

    static class Task {

        public void solve(int testNumber, FastReader scan, PrintWriter out) {
            int r = scan.nextInt();
            out.println(r*r);
        }
    }

    static void shuffle(int[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            int temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static void shuffle(long[] a) {
        Random get = new Random();
        for (int i = 0; i < a.length; i++) {
            int r = get.nextInt(a.length);
            long temp = a[i];
            a[i] = a[r];
            a[r] = temp;
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(new File(s)));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 23124
#! -*- coding:utf-8 -*-
#????????????P????????????3???A,B,C????????£???????????????????§???¢???
#?????´?????????????????´???????????????????????????????????°?????????
#????????????????????????????????¨?????????
#?????????????????§?¨???????
import sys
for line in sys.stdin:
    #1:A,2:B,3:C
    ax,ay,bx,by,cx,cy,px,py = map(float,line.split())
    # AB
    abx = bx-ax
    aby = by-ay
    #BP
    bpx = px-bx
    bpy = py-by
    #BC
    bcx = cx-bx
    bcy = cy-by
    #CP
    cpx = px-cx
    cpy = py-cy
    #CA
    cax = ax-cx
    cay = ay-cy
    #AP
    apx = px-ax
    apy = py-ay

    #outer product
    c1 = abx * bpy - aby * bpx
    c2 = bcx * cpy - bcy * cpx
    c3 = cax * apy - cay * apx

    # print c1
    # print c2
    # print c3
    if (c1>0 and c2>0 and c3>0) or (c1<0 and c2<0 and c3<0):
        print "YES"
    else:
        print "NO"

Measured memory_bytes: 6464
import sys

n, *h = map(int, sys.stdin.read().split())

def main():
    cnt = 0
    for _ in range(max(h)):
        flag = 0
        for i in range(n):
            if not h[i]: flag = 0
            else:
                if not flag:
                    flag = 1
                    cnt += 1
                h[i] -= 1
    print(cnt)

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3060
N = int(input())
out = []
def Saiki(N):
  w = N // 26
  z = N % 26
  ca = 1
  if(z == 0):
    w -= 1
    z = 26
  ca += z - 1
  out.insert(0, chr(ca + 96))
  if(w == 0): return
  Saiki(w)
Saiki(N)
print(''.join(out))

Measured memory_bytes: 9096
a = [list(input())]
a.append(list(input()))
a.append(list(input()))
b = 0
while True:
    c = a[b]
    if len(c) == 0:
        if b == 0:
            print("A")
        elif b == 1:
            print("B")
        elif b == 2:
            print("C")
        exit()
    else:
        c = c.pop(0)
        if c == "a":
            b = 0
        elif c == "b":
            b = 1
        elif c == "c":
            b = 2


Measured memory_bytes: 3064
#include<stdio.h>


#define ll long long

int n, f[10][10];
ll ans;
int main() {
	scanf("%d", &n);
	for(int i=1; i<=n; ++i){
		int x=i;
		while(x>=10) x/=10;
		++f[x][i%10];
	}
	for(int i=1; i<=n; ++i){
		int x=i;
		while(x>=10) x/=10;
		ans+=f[i%10][x];
	}
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dump_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll m, ll n) {
    if ((0 == m) || (0 == n)) return 0;
    return ((m / gcd(m, n)) * n);
}

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

// 素数判定
bool is_prime(ll n) {
    for (int i = 2; i * i <= n; i++) if (n % i == 0) return false;
    return n != 1;
}

// 約数列挙
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    return res;
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        ll div = lcm(c, d);
        cout << b - a + 1 -
                ((b / c + b / d) - (a - 1) / c - (a - 1) / d - b / div + (a - 1) / div)
             << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256