akhauriyash/Code-Regression huggingface dataset:
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

const int N = 2e5 + 5;
ll dp[N][2];

void solve()
{
	int n;
	cin >> n;
	v64 arr(n + 1, 0);
	for (int i = 1; i < n + 1; i++)
		cin >> arr[i];
	memset(dp, 0, sizeof(dp));
	dp[2][1] = arr[2];
	dp[2][0] = arr[1];
	for (int i = 3; i < n + 1; i++)
	{
		if (i & 1)
		{
			ll temp = max({dp[i - 3][1], dp[i - 3][0], dp[i - 2][1], dp[i - 2][0]});
			dp[i][1] = arr[i] + temp;
			dp[i][0] = max({arr[i - 1] + dp[i - 2][0], arr[i - 1] + dp[i - 3][1], arr[i - 1] + dp[i - 3][0], arr[i - 2] + dp[i - 3][0]});
		}
		else
		{
			dp[i][1] = arr[i] + max({dp[i - 2][1], dp[i - 2][0], dp[i - 1][0]});
			dp[i][0] = arr[i - 1] + dp[i - 2][0];
		}
	}
	cout << max(dp[n][1], dp[n][0]) << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


Measured memory_bytes: 7988
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

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

void dfs(int N, int C, int x, int y, vector< vector<int> >& a) {
	a[y][x] = -1;
	for (int k = 0; k < 6; k++) {
		int _x = x + dx[k], _y = y + dy[k];
		if (_y >= 0 && _y < N && _x >= 0 && _x <= _y && a[_y][_x] == C)
			dfs(N, C, _x, _y, a);
	}
}

int f(int N, int C, vector< vector<int> > a) {
	for (int y = 0; y < N; y++)
		for (int x = 0; x <= y; x++) {
			if (a[y][x] != 0) continue;
			for (int k = 0; k < 6; k++) {
				int _x = x + dx[k], _y = y + dy[k];
				if (_y >= 0 && _y < N && _x >= 0 && _x <= _y && a[_y][_x] > 0)
					dfs(N, a[_y][_x], _x, _y, a);
			}
		}
	/*for (int y = 0; y < N; y++) {
		for (int x = 0; x <= y; x++)
			cout << a[y][x] << ' ';
		cout << endl;
	}*/
	int res = 0;
	for (int y = 0; y < N; y++)
		for (int x = 0; x <= y; x++) {
			if (a[y][x] == C) res--;
			else if (a[y][x] > 0) res++;
		}
	return res;
}

int main() {
	for (;;) {
		int N, C; cin >> N >> C;
		if (N == 0) break;
		vector< vector<int> > a(N, vector<int>(N));
		for (int y = 0; y < N; y++)
			for (int x = 0; x <= y; x++)
				cin >> a[y][x];
		int maxi = INT_MIN;
		for (int y = 0; y < N; y++)
			for (int x = 0; x <= y; x++) {
				if (a[y][x] != 0) continue;
				a[y][x] = C;
				maxi = max(maxi, f(N, C, a));
				a[y][x] = 0;
			}
		cout << maxi << endl;
	}
}

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

int main(){
	double a,b;
	while(cin>>a>>b){
		if(a+b==0) break;
		double ans = 1e9;
		for(double i=0;i<a;i+=1.0){
			ans = min(ans, abs(sqrt(i*i+(a-i)*(a-i))-b));
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3260
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int h[100000];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> h[i];
	
	rep(i, n) {
		if (i == 0) {
			h[i]--;
		}
		else {
			if (h[i - 1] > h[i]) {
				cout << "No" << endl;
				return 0;
			}
			if (h[i - 1] < h[i]) {
				h[i]--;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
#include<iomanip>
#include<functional>
#include<limits>
#include <unordered_map>
#include <numeric>
#include <array>
#include <queue>

using namespace std;
using  ull = unsigned long long int;

#define rep(i,n,m) for(long long int i=n;i<(long long int)(m);i++)
#define INF (1<<29)


int main() {



	
	string str;
	cin >> str;


	string yaki = "YAKI";
	string str2 = str.substr(0, 4);
	if (yaki == str2)cout << "Yes" << endl;
	else cout << "No" << endl;



	

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    for(int i=0; i<4; i++)
            cout<<s[i];
    cout<<" ";
    for(int i=4; i<12; i++)
        cout<<s[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int n;
  
void compute(int depth,double x1,double y1,double x2,double y2){
  double si60 = sqrt(3.0)/2.0;
  double co60 = 0.5;
    
  double sx = (x1+x1+x2)/3.0;
  double sy = (y1+y1+y2)/3.0;
  double tx = (x1+x2+x2)/3.0;
  double ty = (y1+y2+y2)/3.0;
    
  double vx = tx-sx;
  double vy = ty-sy;
    
  double ux = sx + co60*vx - si60*vy;
  double uy = sy + si60*vx + co60*vy;
    
  if(depth>=n)return;
    
  compute(depth+1,x1,y1,sx,sy);
  printf("%.8f %.8f\n",sx,sy);
  compute(depth+1,sx,sy,ux,uy);
  printf("%.8f %.8f\n",ux,uy);
  compute(depth+1,ux,uy,tx,ty);
  printf("%.8f %.8f\n",tx,ty);  
  compute(depth+1,tx,ty,x2,y2);
  
    
}
  
int main(){
  cin>>n;
  printf("%.8f %.8f\n",0.0,0.0);
  compute(0,0.0,0.0,100.0,0.0);
  printf("%.8f %.8f\n",100.0,0.0);
  return 0;
}



Measured memory_bytes: 3176
#include<iostream>
using namespace std;
int main(){
  	int a,b,c,d,x,y;
  	cin >> a >> b >> c >> d;
  	x=a;
  	if(a>b)
      	x=b;
  	if(c<d)
      	x+=c;
  	else
      	x+=d;
  	cout << x << endl;
	return 0;
}

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

def f(s):
    ans = 0
    if (int)(s) > n:
        return 0
    for c in '753':
        num = (str)(s+c)
        if (int)(num) <= n:
            if num.count('3')and num.count('5') and num.count('7'):
                ans += 1
            ans += f(num)
    return ans
print(f('0'))


Measured memory_bytes: 3060
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

queue <int> q ;
vector <int> e[N] ;
int n, m, ans ;
int dp[N], in[N] ;

signed main(){
	scanf("%d%d", &n, &m) ;
	for (int i = 1, a, b; i <= m; i++) {
		scanf("%d%d", &a, &b) ;
		e[a].pb(b) ; // directed
		in[b]++ ;
	}
    for (int i = 1; i <= n; i++) if (!in[i]) q.push(i) ;
    while (!q.empty()) {
    	int now = q.front() ; q.pop() ;
    	for (int i = 0; i < siz(e[now]); i++) {
			int to = e[now][i] ;
			in[to]-- ;
			if (!in[to]) {
				dp[to] = dp[now] + 1 ;
				q.push(to) ;
			}
		}
	}
	for (int i = 1; i <= n; i++) ans = max(ans, dp[i]) ;
	printf("%d\n", ans) ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


Measured memory_bytes: 6528
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

// using
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long long ull;

// assert
template <typename T>
void assert_between(T val, T min, T max)
{
    assert(min <= val && val <= max);
}

// math
// 最大公約数(Gratest Common Divisor)を求める.
template <typename T>
T gcd(T a, T b)
{
    assert(a > 0 && b > 0);
    T num1 = max(a, b);
    T num2 = min(a, b);
    T mod = num1 % num2;
    return (mod == 0) ? num2 : gcd(num2, mod);
}

// 最小公倍数(Least Common Multiple)を求める.
template <typename T>
T lcm(T a, T b)
{
    return (a * b) / gcd(a, b);
}

int N = INT32_MAX;
int K = INT32_MAX;
string S = "";

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

    scanf("%d %d", &N, &K);
    cin >> S;
    assert(S.length() == N);

    switch (S[K-1])
    {
    case 'A':
        S[K-1] = 'a';
        break;
    case 'B':
        S[K-1] = 'b';
        break;
    case 'C':
        S[K-1] = 'c';
        break;
    default:
        assert(false);
        break;
    }

    printf("%s\n", S.c_str());
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#define INF 1e9
#define MOD 1000000007
#define ll long long
#define int long long
using namespace std;
typedef unsigned long long ull;
typedef pair<int, int> p;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x,y;
    cin>>x>>y;
    cout<<x+y/2;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x,ans;
    cin>>x;
    long long b;
    b=x;
    ans=0;
    while (b>0){
        ans+=b%10;
        b/=10;
    }
    if (x%ans==0){
        cout<<"Yes";
    }
    else {
        cout<<"No";
    }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll 				long long
#define ld 				long double
#define fastio 			ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) 		cerr<<#x<<" "<<x<<endl
#define cina(a,n) 		for(ll i = 0;i<n;i++)	cin>>a[i];
#define couta(a,n) 		for(ll i = 0;i<n;i++) cout<<a[i]<<" ";
#define fauto(ar)		for(auto x : ar)	cout<<x<<" ";
#define mod 			1000000007
#define siz 			1005 
#define f 				first
#define s 				second
#define pb 				push_back
#define endl 			"\n"
#define ci 				cin.ignore()
using namespace std;
int main()
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	
	if(a+b >= k)
	cout<<min(a,k)<<endl;
	else
	{
		cout<<a + a+b-k;
	}
	
	
	
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector< pi > 
const int N=200010;
ll a[N];
int n;
ll hh(ll mid)
{
    ll r=0;
    for(int i=1;i<=n;i++)
    {
        r+=abs(a[i]-mid-i);
    }
    return r;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    ll l=-mod,r=mod;
    while(l<r)
    {
        ll mid=(l+r)/2;
        if(l==r-1)
        {
            if(hh(r)<hh(l)) l++;
            break;
        }
        if(hh(mid)>hh(mid+1)) l=mid+1;
        else r=mid;
    }
    //cout<<l<<"\n";
    cout<<hh(l);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;
double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	ll N;
	vector<ll>V;
	cin>>N;
	rep(i,N){
		ll t;
		cin>>t;
		V.push_back(t-1);
	}
	ll Comp=0,ANS=0;
	rep(i,N){
		if(V[i]!=Comp)ANS++;
		else Comp++;
	}
	if(ANS==V.size()){
		cout<<-1<<endl;
	}
	else{
		cout<<ANS<<endl;
	}
}

Measured memory_bytes: 2420
import sys, collections
input = sys.stdin.readline

n = int(input())
a = []
for i in range(n):
    a.append(list(map(int, input().split())))
nums = [0 for i in range(n)]
day = 0
match = 0
flag = True
queue = collections.deque([])
temp = set()
for i in range(1, n + 1):
    i2 = a[i - 1][0]
    if a[i2 - 1][0] == i:
        if i not in temp:
            queue.append([i, i2])
            temp.add(i)
            temp.add(i2)
if not queue:
    flag = False
while queue:
    temp = []
    while queue:
        test = queue.popleft()
        match += 1
        num1, num2 = test[0], test[1]
        nums[num1 - 1] += 1
        nums[num2 - 1] += 1
        temp.append(num1)
        temp.append(num2)
    flag2 = False
    temp2 = set()
    for i in temp:
        if nums[i - 1] <= n - 2:
            new_num = a[i - 1][nums[i - 1]]
            if nums[new_num - 1] <= n - 2 and a[new_num - 1][nums[new_num - 1]] == i:
                if i not in temp2:
                    queue.append([i, new_num])
                    flag2 = True
                    temp2.add(i)
                    temp2.add(new_num)
    if flag2 == False and match < n * (n - 1) // 2:
        flag = False
        break
    day += 1

if flag == True:
    print(day)
else:
    print(-1)

Measured memory_bytes: 88944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;
typedef pair<ll,int> P;


int main(){
  string s,t;
  cin>>s>>t;
  int n=t.size();
  vector<int> a[26];
  rep(i,0,n){
    a[(int)s[i]-97].push_back(i);
  }
  string p="Yes";
  rep(i,0,26){
    rep(j,0,a[i].size()){
      if(t[a[i][0]]!=t[a[i][j]]){
        p="No";
      }
    }
  }
  
  vector<int> b[26];
  rep(i,0,n){
    b[(int)t[i]-97].push_back(i);
  }
  rep(i,0,26){
    rep(j,0,b[i].size()){
      if(s[b[i][0]]!=s[b[i][j]]){
        p="No";
      }
    }
  }
  cout<<p<<endl;
}

Measured memory_bytes: 2824
n = gets.to_i
s = gets.strip

count = 0

0.upto(n-2) do |i|
  (i+1).upto(n-1) do |j|
    k = 2 * j - i
    next if k >= n

    if s[i] != s[j] && s[i] != s[k] && s[j] != s[k]
      count += 1
    end
  end
end

puts s.count('R') * s.count('G') * s.count('B') - count

Measured memory_bytes: 14328
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
using namespace std;

using ll = long long;

#define rep_init(i, init, n) for(int i = (init); i < (n); ++i)
#define rep(i, n) rep_init(i, 0, n)

constexpr ll MOD = 998244353;

int main()
{
	int N, S;
	cin >> N >> S;

	vector<int> A(N);
	rep(i, N)
	{
		cin >> A[i];
	}

	vector<vector<ll>> dp(N, vector<ll>(S+1, 0));
	if (A[0] <= S) dp[0][A[0]] = 1;
	dp[0][0] = 2;

	rep_init(i, 1, N)
	{
		rep(j, S+1)
		{
			if (A[i] <= j) (dp[i][j] += dp[i-1][j-A[i]]) %= MOD;
			(dp[i][j] += 2 * dp[i-1][j]) %= MOD;
		}
	}

	cout << dp[N-1][S] << endl;

	return 0;
}

Measured memory_bytes: 73644
n,k = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
M = max(A)
l,r = 1,M
cnt = 0
while l<=r:
    cnt = 0
    mid = (l+r)//2
    for a in A:
        tmp= a//mid if a>mid else 0
        cnt += tmp
    if cnt <=k:
        r = mid-1
    else:
        l = mid+1
print(l)


Measured memory_bytes: 94276
/* こんなウンコードで通ったらしぇか行く */

#include <stdio.h>
#include <string.h>

#define EMPTY 0
#define YET_DELIVERED 1
#define CHURCH 2
#define ALREADY_DELIVERED 3

#define CHURCH_INDEX 30

enum direction {SOUTH, EAST, WEST, NORTH};

typedef struct house {
    struct house *next[4];
    int index;
} House;

int house_bits;
House map[10][10];

int rec(House *house, int depth) {
    int i;
    int sum = 0;
    House *now_house;

    for (i=0; i<4; i++) {
        now_house = house->next[i];

        while (now_house != NULL) {
            if (now_house->index == CHURCH_INDEX) {
                if (depth == house_bits) return 1;
            } else {
                int bit;
                int cond;

                bit = 1 << now_house->index;
                cond = ((bit & depth) == 0);
  
                if (cond) {
                    sum += rec(now_house, bit | depth);
                    break;
                }
            }

            now_house = now_house->next[i];
        }
    }

    return sum;
}

int main() {
    while (1) {
        int i;
        int m, n;
        int church_x;
        int church_y;
        int now_ind;
        House *x_prevs[10];
    
        scanf("%d %d", &m, &n);
        if ( (m & n) == 0) return 0;
           
        now_ind = 0;
        memset(map, 0, sizeof(map));
        memset(x_prevs, 0, sizeof(x_prevs));

        for (i=0; i<n; i++) {
            int j;
            House *y_prev = NULL;

            for (j=0; j<m; j++) {
                int p;
    
                scanf("%d", &p);

                if (p == CHURCH) {
                    church_x = j;
                    church_y = i;

                    map[i][j].index = CHURCH_INDEX;

                    map[i][j].next[NORTH] = x_prevs[j];
                    map[i][j].next[WEST] = y_prev;

                    if (x_prevs[j]) {
                        x_prevs[j]->next[SOUTH] = &map[i][j];
                    }

                    if (y_prev) {
                        y_prev->next[EAST] = &map[i][j];
                    }

                    x_prevs[j] = &map[i][j];
                    y_prev = &map[i][j];
                } else if (p == YET_DELIVERED) {
                    map[i][j].index = now_ind;

                    map[i][j].next[NORTH] = x_prevs[j];
                    map[i][j].next[WEST] = y_prev;

                    if (x_prevs[j]) {
                        x_prevs[j]->next[SOUTH] = &map[i][j];
                    }

                    if (y_prev) {
                        y_prev->next[EAST] = &map[i][j];
                    }

                    x_prevs[j] = &map[i][j];
                    y_prev = &map[i][j];

                    ++now_ind;
                }
            }

            if (y_prev) {
                y_prev->next[EAST] = NULL;
            }
        }

        for (i=0; i<10; i++) {
            if (x_prevs[i]) {
                x_prevs[i]->next[SOUTH] = NULL;
            }
        }

        house_bits = (1 << now_ind)-1;
        printf("%d\n", rec(&map[church_y][church_x], 0));
    }
}

Measured memory_bytes: 1032
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >> y[i];
typedef long long int ll;
using namespace std;

int w,h;
string f[20];
int cnt;

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

void dfs(int x,int y){
	f[y][x]='#';
	cnt++;
	for(int i=0;i<4;i++){
		int nx=x+dx[i];
		int ny=y+dy[i];

		if(nx<0||nx>=w)continue;
		if(ny<0||ny>=h)continue;
		if(f[ny][nx]!='.')continue;

		dfs(nx,ny);
	}
}

int main(){
	while(1){
		cin >> w >> h;
		if(w==0&&h==0)break;
		for(int i=0;i<h;i++){
			cin >> f[i];
		}
		cnt=0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(f[i][j]=='@')dfs(j,i);
			}
		}
		cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 3140
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)

N, Q = map(int, input().split())
tree = [[] for _ in range(N)]
for _ in range(N-1):
  a, b = map(int,input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)

points = [0 for _ in range(N)]
for i in range(Q):
  p, x = map(int, input().split())
  points[p-1] += x

def dfs(v, pv):
  for nv in tree[v]:
    if nv != pv:
      points[nv] += points[v]
      dfs(nv, v)

dfs(0, 0)
print(*points)

Measured memory_bytes: 230892
#include <bits/stdc++.h>
using namespace std;
signed main() {
  int n,m;
  cin >> n >> m;
  int heights[n];
  bool is_good[n];
  for(int i = 0; i < n; ++i) {
    cin >> heights[i];
    is_good[i] = true;
  }

  int ans = n;
  int a, b;
  for(int i = 0; i < m; ++i) {
    cin >> a >> b;
    --a; --b;
    if(heights[a] <= heights[b]) {
      if(is_good[a]) {
        --ans;
        is_good[a] = false;
      }
    }
    if(heights[b] <= heights[a]) {
      if(is_good[b]) {
        --ans;
        is_good[b] = false;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4132
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // input操作
  int N;
  cin >> N;
  vector<vector<int>> graph(N);
  vector<int> c(N);
  vector<int> d(N, -1);
  REP(i, N - 1) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  REP(i, N) cin >> c[i];
  // cは降順
  sort(rall(c));
  // スコアの最大値ansを求める
  ll ans = 0;
  for(int i = 1; i < N; i++) {
    ans += c[i];
  }
  // 幅優先探索で頂点0からはじめてどんどん整数を書き込んでしまう
  queue<int> Q;
  Q.push(0);
  // cのindex, 大きい順に書き込んでいく
  int now = 1;
  // 頂点0に一番大きい数を書く
  d[0] = c[0];
  while(Q.size()) {
    int z = Q.front();
    Q.pop();
    for(int x : graph[z]) {
      // すでに番号がかいてあったらむし
      if(d[x] != -1) { continue; }
      //　番号を書き込む
      d[x] = c[now];
      now++;
      Q.push(x);
    }
  }
  cout << ans << endl;
  REP(i, N) { cout << d[i] << endl; }
  return 0;
}

Measured memory_bytes: 1024
x = int(input())
if x == 2:
  print(2)
  exit()
  
for i in range(1000000):  
  for j in range(2, x+i):
    
    if (x+i) % j == 0:
      break   
         
    if j == x+i-1:
      print(x+i)
      exit()

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

l = {}
for a in A:
    if a in l:
        l[a] += 1
    else:
        l[a] = 1

for i in range(1, N+1):
    if i in l:
        print(l[i])
    else:
        print(0)


Measured memory_bytes: 111424
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define forn(i,a,b) for(ll i=a;i<(ll)b;i++)
int main()
{
    ll a,b;
    cin>>a>>b;
    ll sum=0;
    ll arr[a];
    for(ll i=0;i<a;i++)
    {
        cin>>arr[i];
    }
    sort(arr,arr+a);
    for(ll i=0;i<a-b;i++)
    sum+=arr[i];
    cout<<sum<<"\n";
    return 0;
}

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

int main() {

  int N;
  cin >> N;

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

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

  long long answer = 0;

  for (int i = 0; i < N; i++) {
    
    int mn = min(A[i], B[i]);
    A[i] -= mn;
    B[i] -= mn;
    answer += mn;

    int mn2 = min(A[i+1], B[i]);
    A[i+1] -= mn2;
    B[i] -= mn2;
    answer += mn2;

  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=1e18;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define inf 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 500005
using namespace std;
ll fact[N],invf[N];
long long powmod(long long a,long long po){
	if(po==0)return 1;
	if(po==1)return a;
	long long int p1=powmod(a,po/2ll);
	long long int p2=p1*p1;
	long long p3=powmod(a,po%2ll);
	return ((p2%mod)*(p3%mod))%mod;
}
ll euclid(ll a, ll b, ll &x, ll &y) {
	if (b) { 
		ll d = euclid(b, a % b, y, x);
		return y -= a/b * x, d; 
	}
	return x = 1, y = 0, a;
}
ll modInverse(ll a,ll p=mod){
	ll x,y;
	euclid(a,p,x,y);
	return ((x%p+p)%p);
}
ll ncr(ll n,ll r){
	return fact[n]*invf[r]%mod*invf[n-r]%mod;
}
void solve(){
	ll n,m;
	cin>>n>>m;
	fact[0]=invf[0]=fact[1]=invf[1]=1;
	for(ll i=2;i<=m;i++){
		fact[i]=fact[i-1]*i%mod;
		invf[i]=invf[i-1]*modInverse(i)%mod;
	}
	ll ans=ncr(m,n)*ncr(m,n)%mod*fact[n]%mod*fact[n]%mod;
	for(ll i=1;i<=n;i++){
		ll nci=ncr(n,i);
		ll mci=ncr(m,i);
		ll micni=ncr(m-i,n-i);
		ans=ans+powmod(-1ll,i)*nci%mod*mci%mod*fact[i]%mod*micni%mod*micni%mod*fact[n-i]%mod*fact[n-i]%mod;
		ans%=mod;
	}
	ans+=mod;
	ans%=mod;
	cout<<ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 11404
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define repeat_from_reverse(i, m, n) for( int i = (n) - 1; (i) >= (m); --(i) )
#define el cout<<endl
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t t=0; t<v.size(); ++t){cout << " " << #v << "[" << t << "]=" << v[t];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int a, b;
    cin >> a >> b;
    int ans = a;
    if (b < a) --ans;
    cout << ans << endl;
}    

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int num = 0;
  for(int i = 9; i != 1; i--){
    while(n % i == 0){
      n /= i;
      num++;
    }
  }

  if(n == 1 && num <= 2){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define LIM_A 31

char str[10001];
int N, M;

int K[LIM_A];
int A[LIM_A][LIM_A];

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d %d", &N, &M);

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

void initialize() {
	// nop
}

int count() {
	int flag_all[M+1];
	for (size_t i = 1; i <= M; i++) {
		flag_all[i] = 1;
	}

	for (size_t i = 0; i < N; i++) {
		int flag[M+1];
		for (size_t j = 1; j <= M; j++) {
			flag[j] = 0;
		}

		for (size_t j = 0; j < K[i]; j++) {
			flag[A[i][j]] = 1;
		}

		for (size_t j = 1; j <= M; j++) {
			flag_all[j] = flag_all[j] ? flag[j] : 0;
		}
	}

	int c = 0;
	for (size_t i = 1; i <= M; i++) {
		c += flag_all[i];
	}
	return c;
}

int main(void) {
	receive_input();
	initialize();

	printf("%d\n", count());

	return 0;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 1e4+1;
string s;
int n, D, memo[N][2][100];

int dp(int i, bool lss, int mod){
  if (i == n){
    return (mod == 0);
  }
  if (memo[i][lss][mod] != -1) return memo[i][lss][mod];
  int ans = 0;  
  for (int d = 0; d < 10; d++){
    if (!(d <= s[i] - '0' || lss)) continue;
    ans += dp(i + 1, (lss | d < s[i] - '0'), (mod + d) % D);  
    ans %= MOD;
  }
  return memo[i][lss][mod] = ans;
}

int main()
{
  fastio;
  cin >> s >> D;
  n = s.size();
  for (int i = 0; i <= n; i++){
    for (int j = 0; j < D; j++){
      memo[i][0][j] = memo[i][1][j] = -1;
    }
  }
  cout << (dp(0, 0, 0) - 1 + MOD) % MOD;;
  return 0;
}

Measured memory_bytes: 8832
#include<bits/stdc++.h>
#define maxn 5050
using namespace std;
int n,k,s;
int a[maxn],f[maxn];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	 scanf("%d",&a[i]),a[i]=min(a[i],k),s+=a[i];
	sort(a,a+n+1);
	f[0]=1;
	for(int i=n;i>=0;i--)
	 {
	  bool flag=true;
	  for(int j=k-1;j>=k-s&&j>=0;j--)
	   if(f[j])
	    flag=false;
	  if(flag)
	   {
	   	printf("%d\n",i);
	   	break;
	   }
	  for(int j=k;j>=a[i];j--)
	   f[j]|=f[j-a[i]];
	  s-=a[i];
	 }
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<bitset>
#include<tuple>
#include<time.h>
#include<list>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




void solve(){
	set<int> s;
	int a,b,c;
	cin >> a >> b >> c;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	if(s.size() == 2) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main(){
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 768
if __name__ == "__main__":
    N, W = map(lambda x: int(x), input().split())
    items = [(0, 0, 0)] * N
    for i in range(N):
        v, w, m = map(lambda x: int(x), input().split())
        items[i] = (v, w, m)

    values = []
    weights = []
    for (v, w, m) in items:
        key = 1
        while m > 0:
            values.append(v * key)
            weights.append(w * key)
            m -= key
            key = min(key * 2, m)

    dp = [0 for i in range(W + 1)]
    for i in range(len(values)):
        wi = weights[i]
        vi = values[i]
        for w in range(W, wi - 1 , -1):
            if (dp[w] < dp[w - wi] + vi):
                dp[w] = dp[w - wi] + vi

    print(dp[W])



Measured memory_bytes: 6016
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		while(true){
			String[] line = br.readLine().split(" ");
			int h = Integer.parseInt(line[0]);
			int w = Integer.parseInt(line[1]);
			if( h==0 && w==0 ) break;
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					if( (i % 2 == 0 && j % 2 != 0) || (i % 2 != 0 && j % 2 == 0) ) sb.append(".");
					else sb.append("#");
				}
				sb.append("\n");
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int a, b;
	cin >> a >>b;
	if (a > 8 || b > 8 ) cout << ":(" << endl;
	else cout << "Yay!" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl       "\n"
#define ll         long long
#define pb         push_back
#define FIO        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define NUM        1000000007
#define MOD        998244353
#define F          first
#define S          second
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define per(i,a,b) for(ll i=a-1;i>=b;i--)
#define vi         vector<ll>
#define pii        pair<ll,ll>
#define vpi        vector<pii>
#define mi         map<ll,ll>
#define mpi        map<pii,ll>
#define all(v)     (v).begin(),(v).end()
#define rall(v)    (v).rbegin(),(v).rend()
#define fac(a)     tgamma(a+1)
#define INF        LONG_LONG_MAX
#define NINF       LONG_LONG_MIN
#define N          1000005

ll a,b,c,d,e,i,j,k,l,m,n,q,r,u,v,w,x,y,z,mn,mx,dx,dy;

int main() 
{
    FIO;
    ll t=1;
    //cin >> t;
    while(t--)
    {
        cin>>n>>d;
        ll ans=0;
        while(n--)
        {
            cin>>x>>y;
            if(x*x+y*y<=d*d)ans++;
        }
        cout<<ans;
        
        
        
        
        
    }
    return 0;
}


Measured memory_bytes: 3660
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);


    while(cin >> n)
    {
		ans = 0;
		for(ll i = 1; i <= n; i++)
		{
			ans = (ans + (i * (n - i + 1)));
		}

		for(ll i = 1; i < n; i++)
		{
			ll u, v;
			slld(u);
			slld(v);

			if(u > v) swap(u,v);

			ans -= u * (n - v + 1);
		}

		printf("%lld\n", ans);
    }


}





Measured memory_bytes: 3804
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

int inf = 1000000000;
int main(){
    int a,b,ans;
    cin >>a >>b;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    ans = (b-1)/(a-1);
    if((b-1)%(a-1) != 0)ans++;
    cout << ans << endl;
}

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

public class Main {


	public static void main(String[] args) {
		Main ans = new Main();
		System.out.println(ans.solve());
	}

	private long solve() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int [] array = new int[N+1];
		for(int i=1;i<=N;i++) {
			array[i] = sc.nextInt();
		}

		long [][] dp = new long[N+2][K+2];
		for(int i=0;i<=K;i++) {
			dp[1][i] = ((i<=array[1]) ? 1 : 0);
		}
		long MOD = (long)(1e9+7);

		for(int i=2;i<=N;i++){
			for(int j=0;j<=K;j++) {
				dp[i][j] = (MOD+ dp[i-1][j] + ((j==0) ? 0 :dp[i][j-1]) - (((j-1-array[i])>=0) ? dp[i-1][j-1-array[i]] : 0))%MOD;				
			}
		}
		return dp[N][K];
	}

 
}

Measured memory_bytes: 139868
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)
//Map<String, Integer> map = new HashMap<String, Integer>(n);
//ArrayList<String> cc = new ArrayList<>(n);

public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	
	
	public static void main(String[] args) {
	long n=sc.nextInt();
	long k=sc.nextInt();
	long list[]=new long[(int) n];
	for(long i=0;i<n;i++) {
		list[(int) i]=sc.nextInt();
	}
	Arrays.sort(list);
	long ans=0;
	for(long i=0;i<n-k;i++) {
		ans+=list[(int) i];
	}
	p(ans);
 }
}


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

char a[100000], b[100000], c[100000];
int q, w, e;
int main()
{
	scanf("%s %s %s", &a, &b, &c);
	q = a[0];
	w = b[0];
	e = c[0];
	q -= 32;
	w -= 32;
	e -= 32;
	a[0] = q;
	b[0] = w;
	c[0] = e;
	printf("%c%c%c\n", a[0], b[0], c[0]);
	return 0;
}

Measured memory_bytes: 128
N, M, X = map(int, input().split())
book_list = []
for i in range(N):
    book_list.append(list(map(int, input().split())))

nedan = 0
nedan_mazi = 12*10**15
flag = 0

for i in range(2**N):

    bag = []
    for j in range(N):
        if (i >> j) & 1:
            bag.append(j)

    rikai = [0] * M
    for t in bag:
        for k in range(M):
            rikai[k] += book_list[t][k+1]

    for p in range(M):
        flag=0
        if rikai[p] < X:
            flag = 1
            break

    if flag != 1:
        nedan=0
        for s in bag:
            nedan += book_list[s][0]
    else:
        nedan = 12*10**15

    nedan_mazi = min(nedan, nedan_mazi)


if nedan_mazi == 12*10**15:
    nedan_mazi = -1

print(nedan_mazi)


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

int main() {
	long N; cin >> N;
	vector<int> dig(10000);
	int d;
	for(d=0; true; ++d){
	    if(N%2==0) dig[d]=0;
	    else{
	        dig[d]=1;
	        --N;
	    }
	    N /= -2;
	    if(N==0) break;
	}
	for(int i=d; i>=0; --i) cout << dig[i];
	cout << endl;
	return 0;
}


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

#define slld(longvalue) scanf("%lld", &longvalue)
#define plld(longvalue) printf("%lld\n", longvalue)

#define slf(longvalue) scanf("%lf", &longvalue)
#define plf(longvalue) printf("%lf\n", longvalue)
#define sc(letter) scanf("%c", &letter)
#define pc(letter) printf("%c", letter)

#define ss(name) scanf("%s", name)
#define ps(name) printf("%s", name)

#define pnew printf("\n")

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >
#define pii pair < int, int >

#define printcase(indexing,ans) printf("Case %lld: %lld\n", indexing, ans)

#define pb(x) push_back(x)

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000009


using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    string str;

    cin >> str;

    if(str[2] == str[3] && str[4] == str[5]) cout << "Yes" << endl;
    else cout << "No" << endl;

}





Measured memory_bytes: 256
import itertools

n = [int(x + 1) for x in range(int(input()))]
p = [int(x) for x in input().split()]
q = [int(x) for x in input().split()]

seq = list(itertools.permutations(n))

for i in range(len(seq)):
    if seq[i] == tuple(p):
        a = i
    if seq[i] == tuple(q):
        b = i

print(abs(a - b))


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

int main() {
  long A, B, K;
  cin >> A >> B >> K;

  if (K >= A) {
    K -= A;
    A = 0;
  } else {
    A -= K;
    K = 0;
  }

  if (K >= B) {
    B = 0;
  } else {
    B -= K;
  }

  cout << A << ' ' << B << endl;
  return 0;
}


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

int main(){
  int i,j,N,M,Q;
  cin >> N >> M >> Q;
  vector<int> A(Q),B(Q),C(Q),D(Q);
  for(i=0; i<Q; i++){
    cin >> A[i] >> B[i] >> C[i] >> D[i];
  }
  queue<pair<int,vector<int>>> que;
  vector<int> tmp(1,1);
  que.push(make_pair(1,tmp));
  pair<int,vector<int>> pat,newp;
  int num,last,score,An=0;
  while(que.size()){
    pat = que.front(); que.pop();
    num = pat.first;
    last = pat.second[num-1];
    tmp = pat.second;
    score=0;
    if(num == N){
      for(i=0; i<Q; i++){
        if(pat.second[B[i]-1]-pat.second[A[i]-1] == C[i]) score += D[i];
      }
      An = max(score,An);
    }
    else{
      num++;
      for(i=last; i<=M; i++){
    	newp = make_pair(num,tmp);
        newp.second.push_back(i);
        que.push(newp);
      }
    }
  }
  cout << An;
  return 0;
}

Measured memory_bytes: 7208
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    string s;
    ll k;
    in(s,k);
    ll kaisuu=0,d=1,e=1,ans=0;
    int i=0;
    while(s[i]==s[i+1]){
        d++;
        i++;
    }
    if(i==s.length()-1){
        out(s.length()*k/2);
        return 0;
    }
    ans+=d/2;
    i=s.length()-1;
    while(s[i]==s[i-1]){
        e++;
        i--;
    }
    ans+=e/2;
    ll kaisuu1=0;
    if(s[0]==s[s.length()-1]){
        kaisuu1=(d+e)/2;
    }else{
        kaisuu1=d/2+e/2;
    }
    debug(kaisuu1);
    for(int i=d;i<s.length()-e;i++){
        d=1;
        while(s[i]==s[i+1]){
            d++;
            i++;
        }
        kaisuu+=d/2;
    }
    out(kaisuu*k+kaisuu1*(k-1)+ans);
}

Measured memory_bytes: 3748
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int N = parseInt(sc.next());
		int T = parseInt(sc.next());
		CtClass[] ct = new CtClass[N];
		for(i=0;i<N;i++) {
			ct[i] = new CtClass(parseInt(sc.next()), parseInt(sc.next()));
		}
		sc.close();
		Arrays.sort(ct,(a, b)-> a.t -b.t);
		int min=1001;
		for(i=0;i<N;i++) {
			if(ct[i].t > T) break;
			if(ct[i].c < min) min =ct[i].c; 
		}
		if(min == 1001) System.out.println("TLE");
		else System.out.println(min);
	}
}
class CtClass {
	int c;
	int t;
	CtClass(int c, int t) {
		this.c = c;
		this.t = t;
	}
}

Measured memory_bytes: 25940
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()
struct FastIO
{
  FastIO() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(0); 
  }
}fastio;

const int MAX = 1e5+10;

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> went(n,0);
	std::vector<std::vector<int> > X(MAX);
	std::vector<std::vector<int> > Y(MAX);
	std::vector<std::pair<int,int> > points;
	std::vector<std::vector<std::pair<int,int> > > connected;
	points.reserve(n);
	rep(i,n) {
		int x,y;
		std::cin >> x >> y;
		points.emplace_back(x,y);
		X[x].emplace_back(i);
		Y[y].emplace_back(i);
	}
	std::function<void(std::pair<int,int>)> dfs = [&](std::pair<int,int> point) {
		for(auto i:X[point.first]) {
			int y = points[i].second;
			if(went[i]) continue;
			connected[connected.size()-1].emplace_back(point.first,y);
			went[i] = true;
			dfs(std::make_pair(point.first,y));
		}
		for(auto i:Y[point.second]) {
			int x = points[i].first;
			if(went[i]) continue;
			connected[connected.size()-1].emplace_back(x,point.second);
			went[i] = true;
			dfs(std::make_pair(x,point.second));
		}
	};
	for(int i=0;i<n;i++) {
		if(went[i]) continue;
		auto p = points[i];
		connected.push_back(std::vector<std::pair<int,int> > ());
		connected[connected.size()-1].emplace_back(p);
		went[i] = true;
		dfs(p);
	}
	int sum = 0;
	for(auto&& i:connected) {
		std::set<int> ux;
		std::set<int> uy;
		for(auto&& j:i) {
			ux.emplace(j.first);
			uy.emplace(j.second);
		}
		sum += ux.size()*uy.size()-i.size();
	}
	print(sum);
	return 0;
}


Measured memory_bytes: 27504
#include<iostream>
using namespace std;
int main(){
	int a[10],i,j,n;
	
	for(int i=0;i<10;i++){
	cin>>a[i];
	}
	for(int i=0;i<9;i++){
		for(j=i+1;j<10;j++){
			if(a[i]<a[j]){
			n=a[i];
			a[i]=a[j];
			a[j]=n;
			}
		}
	}
	
	for(int i=0;i<3;i++){
	cout<<a[i]<<endl;
	}
	
	
	
	return 0;
}

Measured memory_bytes: 1160