akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,k;
  cin>>h>>w>>k;
  string c[h];
  int ans=0;
  for(int i=0;i<h;i++)
    cin>>c[i];
  for(int i=0;i<((1<<h)-1);i++)
    for(int j=0;j<((1<<w)-1);j++){
      int blackn=0;
      for(int p=0;p<h;p++)
        for(int l=0;l<w;l++)
          if(((i>>p)&1)==0&&((j>>l)&1)==0&&c[p][l]=='#') blackn++;
      if(blackn==k)
        ans++;
    }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3592
n,m=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(m)]
import collections 
d=collections.defaultdict(int)
for x,y in a:
    d[x]+=1
    d[y]+=1
for i in range(n):
    print(d[i+1])

Measured memory_bytes: 3316
import sys
input = sys.stdin.readline

def func():
    N = int(input())
    A = [int(i) for i in input().split()]

    dp = [[0] * (N+1) for i in range(N+1)]
    if (N - 1) % 2 == 0:
        fl = 1
    else:
        fl = -1
    for i in range(N):
        dp[i][i+1] = fl * A[i]

    for s in range(2, N+1):
        for l in range(N-s+1):
            r = l + s
            if (N - s) % 2 == 0:
                dp[l][r] = max(dp[l+1][r]+A[l], dp[l][r-1]+A[r-1])
                continue
            dp[l][r] = min(dp[l+1][r]-A[l], dp[l][r-1]-A[r-1])
                
    return dp[0][N]

print(func())

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/12  Problem: ABC 082 D / Link: http://abc082.contest.atcoder.jp/tasks/abc082_d  ----- */


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

	string s; cin >> s;
	int x, y; cin >> x >> y;
	VVI poss(2, VI(1, 0));
	{
		int mode = 0;
		for (auto c : s) {
			if (c == 'F') {
				poss[mode].back()++;
			}
			else {
				poss[mode].push_back(0);
				mode ^= 1;
			}
		}
	}
	const int base = 10000;
	auto f = [](const VI& xs, bool first) {
		bitset<2 * base>a;
		a[base] = 1;
		FOR(i, 0, SZ(xs)) {
			int dx = xs[i];
			bitset<2 * base>nx;
			nx |= a << dx;
			if (i || first)nx |= a >> dx;
			a = nx;
		}
		return a;
	};
	auto X = f(poss[0], 0);
	auto Y = f(poss[1], 1);
	cout << (X[base + x] && Y[base + y] ? "Yes" : "No") << "\n";

	return 0;
}


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

count_max = 0
count = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
        count_max = max(count_max, count)
    else:
        count = 0
print("Yes" if count_max >= 3 else "No")

Measured memory_bytes: 62340
# Greatest Common Divisor

numbers = [int(i) for i in input().rstrip().split()]
a = numbers[0]
b = numbers[1]

def gcd(a, b):
    gcd = 1
    while a != 0 and b != 0:
        if a >= b:
            a %= b
        else:
            b %= a
    if a == 0:
        gcd = b
    else:
        gcd = a
    return gcd

print(gcd(a, b))



Measured memory_bytes: 5604
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

c=input()
data={x for x in "a i u e o".split()}
if c in data:
    print("vowel")
else:
    print("consonant")


Measured memory_bytes: 38384
//	C++ (Clang3.8.0)
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
	int k, n;
	int *a;
	int *ar; // ar[p] = a[p] - a[p-1]
	int max = 9999999;
	
	cin >> k >> n;
	a = new int[n];
	ar = new int[n];
	
	for(int i=0; i<n; ++i){
		cin >> a[i];
		if(i != 0){
			ar[i] = a[i] - a[i-1];
		}
	}
	ar[0] = k-a[n-1]+a[0];
	max = ar[0];
	
	for(int i=1; i<n; ++i){
		if(max < ar[i]){
			max = ar[i];
		}
	}
	
	cout << k-max;
	
	delete[] a;
	delete[] ar;
	
	return 0;
}

Measured memory_bytes: 2424
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//printf("%.12lf\n",mid);
//const long long sze = 2*(2^(long long)(ceil(log(100000)/log(2))));
/*
// get part of decimal
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
const long long mod = 1000000007;
const double eps = .0000000001;
inline void prep()
{
    cin.tie(0);
    cin.sync_with_stdio(0);
};

int main(){
    prep();
    int n;
    cin >> n;
    int costs[n];
    int costs2[n];
    vector<pair<long long, int> > v;
    for (int i=0; i<n; i++){
      cin >> costs[i];
      cin >> costs2[i];
      v.push_back({costs[i]+costs2[i], i});
    }
    sort(v.rbegin(), v.rend());
    bool turn = true;
    long long sum1 = 0;
    long long sum2 = 0;
    for (int i=0; i<n; i++){
      if (turn){
        sum1 += costs[v[i].second];
      }else{
        sum2 += costs2[v[i].second];
      }
      turn = !turn;
    }
    //cout << sum1 << " " << sum2 << endl;
    cout << sum1-sum2;
    return 0;
}      

Measured memory_bytes: 3956
N, D = map(int, input().split())

X = []
for n in range(N):
  X.append(list(map(int, input().split())))
cnt = 0

for i in range(N - 1):
  for j in range(i + 1, N):
    sum = 0
    for d in range(D):
      sum += (X[i][d] - X[j][d]) ** 2
    if (sum ** (1/2)) % 1 == 0:
      cnt += 1
print(cnt)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  string s;
  cin>>s;
  if(s[2]==s[3]&&s[4]==s[5]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int32_t n, *a, *b;

void swap (int32_t *x, int32_t *y) {
    int32_t t = *x;
    *x = *y;
    *y = t;
}

int32_t main(){
    scanf("%d", &n);
    a = (int32_t*)malloc(n * sizeof(int32_t));
    b = (int32_t*)malloc(n * sizeof(int32_t));

    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < n; i++) scanf("%d", &b[n - i - 1]);

    bool bad = false;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i]) {
            bool ok = false;
            for (int j = 0; j < n; j++) {
                if (a[i] != b[j] && a[j] != b[i]) {
                    swap(&b[i], &b[j]);
                    ok = true;
                    break;
                }
            }

            if (!ok) {
                bad = true;
                break;
            }
        }
    }

    if (bad) {
        puts("No");
        exit(0);
    }

    puts("Yes");
    for (int i = 0; i < n; i++) printf("%d ", b[i]);
    puts("");
    free(a); free(b);
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int n = i;
    int cnt = 0;
    while (n) {
      n /= 10;
      cnt++;
    }
    if (cnt % 2 == 1) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define MAX_N 200000
#define MAX_Q 200000

vector<int> v[MAX_N+1];
int count[MAX_N+1] = {0};
int visited[MAX_N+1] = {0};

int dfs(int p, int x) {
    if (visited[p] != 0) return 0;
    count[p] += x;
    visited[p] = 1;
    for (int i = 0; i < (int)v[p].size(); i++) {
        dfs(v[p][i], count[p]);
    }
    return 0;
}

int main() {
    int N, Q;
    cin >> N >> Q;
    int a, b;
    for (int i = 0; i < N-1; i++) {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int p, x;
    for (int i = 0; i < Q; i++) {
        cin >> p >> x;
        count[p] += x;
    }

    dfs(1, 0);

    for (int i = 1; i < N+1; i++) {
        cout << count[i] << " ";
    }
    cout << endl;

    return 0;
}


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

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

    vector<long> h(n);

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

    vector<int> a(m),b(m);
    vector<bool> not_good(n);

    for(int i=0; i<m; i++){
        cin>>a[i]>>b[i];
        if(h[a[i]-1]>h[b[i]-1]){
            not_good[b[i]-1]=true;
        }else if(h[a[i]-1]<h[b[i]-1]){
            not_good[a[i]-1]=true;
        }else{
            not_good[a[i]-1]=true;
            not_good[b[i]-1]=true;
        }
    }

    int count=0;

    for(int i=0; i<n; i++){
        if(not_good[i]==false){
            count++;
        }
    }

    cout<<count<<endl;
}

Measured memory_bytes: 4792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

string ans;
int n, k;

string solve(string s) {
	if (k == 1) return s;
	int m = 0;
	while(m < n && s[n - m - 1] == s[n - 1]) m++;
	int z = m << (k - 2);
	z = min(z, n);
	char t = s[n - 1];
	if (2 * z >= n) {
		for (int i = 0; i < n; i++)
			s[i] = t;
		return s;
	}
	s = s.substr(n - m - (n - z), n - z);
	reverse(s.begin(), s.end());
	for (int i = 0; i < z; i++)
		s[(int)s.length() - z + i] = t;
	for (int i = 0; i < z; i++)
		s.push_back(t);
	reverse(s.begin(), s.end());
	reverse(s.begin() + 2 * z, s.end());
	return s;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	string s;
	cin >> n >> k >> s;
	k = min(k, 15);
	ans = s;
	string p = s;
	reverse(p.begin(), p.end());
	p = s + p;
	for (int i = 0; i <= n; i++)
		ans = min(ans, solve(p.substr(i, n)));
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
'use strict'

const main = (input) => {
    input = input.split(' ').map(i => parseInt(i))
    const A = input[0]
    const B = input[1]
    const C = input[2]
    if(A + B >= C){
        console.log('Yes')
    }else{
        console.log('No')
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

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

bool solve(const int N, const string& s)
{
    if (s.front() == s.back()) return N % 2 == 1;
    else return N % 2 == 0;
}

int main()
{
    string s; cin >> s;
    const auto N = int(s.size());
    cout << (solve(N, s) ? "Second" : "First") << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1023456789
#define sacnf scanf
#define scnf scanf
#define scnaf scanf
#define CRLF <<'\n';
#define ALL(v) v.begin,v.end()
#define SIZE(v) (int)v.size()
#define PRPAIR(x) x.first << x.second
#define DEBUG(x) do { std::cerr <<(x)<<'\n'; } while (0)
#define rep(i,a,b) for(int i=(a);i!=(int)b-((a)>(b));(a)>(b)?--i:++i)
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> pip;
typedef vector<int> vi;
typedef long long ll;
#define MAXN 1000005

int k,n,arr[MAXN];

inline int ceiling(int n,int k){
    if (n%k==0)
        return n/k;
    else
        return n/k+1;
}

bool bsta(int t){
    ll c=0;
    rep(i,0,n){
        c+=ceiling(arr[i],t)-1;
    }
    return c <= k;
}

int main(){
    scanf("%d%d",&n,&k);

    int l=1,r=0;
    rep(i,0,n)
        scanf("%d",&arr[i]),r=max(r,arr[i]);

    int ans=INF;
    while(l <r){
        int mid =(l+r)/2;
        if (bsta(mid)){
            ans = min(ans,mid);
            r=mid;
        }else
            l=mid+1;
    }
    if (ans == INF){
        ans=0;
        rep(i,0,n){
            ans =max(ans,arr[i]);
        }
    }
    cout << ans;

}


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


int main(){
double t,x;
cin >> t >> x;

double ans;
ans = t/x;
cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
WW = list(map(int,input().split()))

Wsum = sum(WW)
phalf = 0
ohalf = 0

psum = 0
for i in range(N):
    psum += WW[i]
    if psum > Wsum / 2:
        ohalf = psum
        phalf = psum - WW[i]
        break
        
difp = Wsum - phalf * 2
difo = ohalf - (Wsum - ohalf)

print(min(difp,difo))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <cmath>
using namespace std;
typedef complex<double> xy_t;

double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }
int main(){
  int n;
  cin >> n;
  vector<xy_t> p(n);
  for(int i = 0; i < n; i++){
    int x,y;
    cin >> x >> y;
    p[i] = xy_t((double)x,(double)y);
  }

  double sum = 0.0;
  for(int i = 0; i+2 < n; i++){
    xy_t a = p[0], b = p[i+1], c = p[i+2];
    sum += cross_product(b-a, c-a) / 2.0;
  }

  printf("%.1f\n", abs(sum));
}

Measured memory_bytes: 3236
#include<iostream>
#include<vector>

using namespace std;

int main(){
	int N; cin >> N;
	vector<int> H(N); for(int i = 0; i < N; ++i) cin >> H[i];
	vector<int> tmp(N, 0);

	int cnt = 0, maxcnt = 0;
	for(int i = 0; i < N-1; ++i){
		if(H[i] - H[i+1] >= 0){
			cnt++;
			if(cnt > maxcnt) maxcnt = cnt;
		}else{
			cnt = 0;
		}
	}

	cout << maxcnt << endl;

	return 0;
}


Measured memory_bytes: 1024
import           Control.Applicative
import           Control.Monad
import           Data.List

main :: IO ()
main = do
  datasets <- lines <$> getContents
  putStr $ unlines $ map show $ process datasets []
    where
      process ("0":_) results = results
      process (num:nums:others) results = process others (results ++ [stdVar])
        where
          n = read num
          a = map (read::String->Double) $ words nums
          avg = (sum a) / n
          var = (sum $ map (\x -> (x- avg)^2) a) / n
          stdVar = sqrt var



Measured memory_bytes: 4960
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<climits> //INT_MIN/MAX
using namespace std;

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

#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(ll (i)=(s);(i)>(e);(i)--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = { 0,0,1,-1,1,1,-1,-1 };
int dy[8] = { 1,-1,0,0,1,-1,1,-1 };

/* -----  xtimex  Problem: ARC070 A / Link:  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

ll N;

ll ans = 0LL;

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

	cin >> N;
	ll s = 0;
	FOR(i, 1, N + 1) {
		s += i;
		if (s >= N) {
			ans = i;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int count[4][3][10] = { 0 };
	int n, b, f, r, v;
	int i = 0;
	int s, t, u;

	scanf("%d", &n);
	while (i < n){
		scanf("%d %d %d %d", &b, &f, &r, &v);
			count[b - 1][f - 1][r - 1] += v;
		i++;
	}

	for (s = 0; s < 4; s++){
		for (t = 0; t < 3; t++){
			for (u = 0; u < 10; u++){
				printf(" %d", count[s][t][u]);
			}
			printf("\n");
		}
		if (s < 3) printf("####################\n");
	}
	return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    long long a, b, k; cin >> a >> b >> k;
    a -= k;
    if (a < 0) b += a;
    cout << max(0LL, a) << " " << max(0LL, b) << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);

		int ninzu=0;
		int p_min=0;
		int p_max=0;
		int[] tens;
		int diff=0;

		while(true) {
			ninzu=sc.nextInt();
			p_min=sc.nextInt();
			p_max=sc.nextInt();

			if(ninzu*p_min*p_max==0) {
				System.exit(0);
			}
			tens=new int[ninzu];

			for(int i=0; i<ninzu; i++) {
				tens[i]=sc.nextInt();
			}
			int diftn=0;
			int tmpd=0;
			int sontoki=0;
			for(int i=p_min; i<=p_max; i++) {
				tmpd=tens[i-1]-tens[i];
				if(tmpd>=diftn) {
					diftn=tmpd;
					sontoki=i;
				}
			}
			System.out.println(sontoki);
		}
	}
}


Measured memory_bytes: 56540
#ifdef ONLINE_JUDGE
  #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#endif

#include "bits/stdc++.h"
using namespace std;
#define int long long

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))

vector<int> v; int d;
const int mod = 1e9 + 7;
int pre[2][101][10001];
bool vis[2][101][10001];
int dp(bool f, int remainder, int pos) {
  if (vis[f][remainder][pos]) return pre[f][remainder][pos];
  vis[f][remainder][pos] = true;
  if (pos == v.size()) {
    return pre[f][remainder][pos] = remainder == 0;
  }
  int x = 0;
  for (int r = 0; r <= (f ? 9 : v[pos]); r ++) {
    x = (x + dp(f || (r < v[pos]), (remainder + r) % d, pos + 1)) % mod;
  }
  return pre[f][remainder][pos] = x;
}

signed main() {
  #ifndef ONLINE_JUDGE
    ifstream cin("in");
  #endif
  ios_base::sync_with_stdio(0); cin.tie(0); // harris leung ioi gold calling it 18.09

  string s; cin >> s >> d;
  for (char c : s) v.push_back(c - '0');
  cout << (dp(0, 0, 0) + mod - 1) % mod << endl;
}

Measured memory_bytes: 22276
#include <iostream>
#include <fstream>

using namespace std;

class DisjSet{
public:
    int numOfNode; // number of nodes
    int* parent; // parent nodes
    int* rankArr; //rankArr of each node
    DisjSet(int x);
    int findSet(int node);
    int findSetWithPC(int x); // findSet() operation with path compression
    void unionByRank(int x, int y);
    bool same(int x, int y); // check whether x and y are in the same set
};

int main()
{
//    // import data from a txt file
//    int n; // number of nodes
//    int q; // number of queries
//    int a, b, c;
//    ifstream infile("input.txt");
//    infile >> n >> q;
//    cout << n << " " << q << endl;
//    DisjSet mySet(n);
//    char output[q]; // sample output: 0 -> skip, 1 -> return yes ("
//    for (int i = 0; i < q; i++) {
//        infile >> a >> b >> c;
//        cout << a << " " <<  b << " " << c << endl;
//        if (a == 0) { // "unite(x,y)"
//            mySet.unionByRank(b, c);
//            output[i] = 'n';
//        }
//        else if (a == 1) { // "same(x, y)"
//            if (mySet.same(b, c)) { output[i] = '1'; }
//            else { output[i] = '0'; }
//        }
//    }
//    infile.close();

    // import data from command line
    int n; // number of nodes
    int q; // number of queries
    int a, b, c;
    cin >> n >> q;
    DisjSet mySet(n);
    char output[q]; // sample output: 0 -> skip, 1 -> return yes ("
    for (int i = 0; i < q; i++) {
        cin >> a >> b >> c;
        if (a == 0) { // "unite(x,y)"
            mySet.unionByRank(b, c);
            output[i] = 'n';
        }
        else if (a == 1) { // "same(x, y)"
            if (mySet.same(b, c)) { output[i] = '1'; }
            else { output[i] = '0'; }
        }
    }

    //print out the output
    for (int i = 0; i < q; i++) {
        if (output[i] != 'n') { cout << output[i] << endl; }
    }
    return 0;
}

DisjSet::DisjSet(int x) {
    numOfNode = x;
    parent = new int[numOfNode];
    rankArr = new int[numOfNode];
    for (int i = 0; i < numOfNode; i++) {
        parent[i] = i;
        rankArr[i] = 1;
    }
}

int DisjSet::findSet(int node) {
    if (parent[node] != node) {
        return findSet(parent[node]);
    } else {
        return parent[node];
    }
}

int DisjSet::findSetWithPC(int x) {
    if (parent[x] !=  x) {
        parent[x] = findSetWithPC(parent[x]);
    }
    return parent[x];
}

void DisjSet::unionByRank(int x, int y) {
    int xrep = findSetWithPC(x); // representative of node x
    int yrep = findSetWithPC(y); // representative of node y
    if (xrep == yrep) {
        return; // do nothing since x and y are curently in the same set
    }
    else if (rankArr[xrep] > rankArr[yrep]) {
        parent[yrep] = xrep;
    }
    else if (rankArr[xrep] < rankArr[yrep]) {
        parent[xrep] = yrep;
    }
    else {
        // rankArr[xrep] = rankArr[yrep]
        parent[xrep] = yrep;
        rankArr[yrep] += 1;
    }
}

bool DisjSet::same(int x, int y) {
    if (findSetWithPC(x) == findSetWithPC(y)) {
        return true;
    }
    else {
        return false;
    }
}



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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int a = stoi(s.substr(0, 2));
    int b = stoi(s.substr(2, 2));
    if(a <= 12 and b <= 12 and a > 0 and b > 0) {
        cout << "AMBIGUOUS" << ln;
    } else if(a <= 12 and a > 0) {
        cout << "MMYY" << ln;
    } else if(b <= 12 and b > 0) {
        cout << "YYMM" << ln;
    } else {
        cout << "NA" << ln;
    }
    return 0;
}


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

int main(){

 int m1,m2,d1,d2;

 cin>>m1>>d1;
  cin>>m2>>d2;

  if(m2 > m1 && d1>d2)
    cout<<"1"<<endl;
  else
    cout<<"0"<<endl;


 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#define nmax_def 110
#define Cmax_def 2200
#define mod 1000000007
using namespace std;
typedef long long ll;

int main() {
	int i, j;
	int N, M;
  	cin>>N>>M;
  	int ans = 0;
  	int M_sqrt = sqrt(M);
  	for(i=1;i<=M_sqrt;i++)
    {
      if(M%i==0)
      {
      	int anstmp = i;
        if(M / N >= anstmp)
          ans = max(ans, anstmp);
        anstmp = M / i;
        if(M / N >= anstmp)
          ans = max(ans, anstmp);        
      }
    }
  cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
sub = sum(a) - 2 * a[0]
asub = abs(sub)

for i in range(1, n-1):
    sub -= 2 * a[i]
    if abs(sub) < asub:
        asub = abs(sub)
print(asub)


Measured memory_bytes: 23800
#include <bits/stdc++.h>
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define mt make_tuple
using namespace std;

const int N = 805;

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

int used[N][N];
int h, w, k;
char grid[N][N];
queue<pair<int, int>> q;

int man(int x1, int y1, int x2, int y2) {
	return abs(x1 - x2) + abs(y1 - y2);
}

int go(int x, int y) {
	q.push({x, y});
	int ret = 1 << 30;
	int xx = x, yy = y;
	int kk = k;
	used[x][y] = 1;
	while (!q.empty()) {
		auto ft = q.front(); q.pop();
		x = ft.fst, y = ft.snd;
//		used[x][y] = 1;
		ret = min(ret, (x + k - 1) / k + 1);
		ret = min(ret, (y + k - 1) / k + 1);
		ret = min(ret, (h - x + k - 2) / k + 1);
		ret = min(ret, (w - y + k - 2) / k + 1);
		for (int k = 0; k < 4; k++) {
			int xk = x + dx[k];
			int yk = y + dy[k];
			if (xk < 0 || xk >= h || yk < 0 || yk >= w) continue;
			if (used[xk][yk]) continue;
			if (grid[xk][yk] == '#') continue;
			if (man(xx, yy, xk, yk) > kk) continue;
			used[xk][yk] = 1;
			q.push({xk, yk});
		}
	}
	return ret;
}

int main() {
	scanf("%d%d%d", &h, &w, &k);
	for (int i = 0; i < h; i++) scanf("%s", grid[i]);
	for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) if (grid[i][j] == 'S') {
		int ans = go(i, j);
		printf("%d\n", ans);
		return 0;
	}
	return 0;
}

Measured memory_bytes: 3456
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
 double r;
  cin>>r;
  double m,e,pi;
  pi=3.141592653589;
  m=r*r*pi;
  e=2*r*pi;
  printf("%f %f\n",m,e);
  return 0;
}

Measured memory_bytes: 1232
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    int n,k;
    cin >> n >> k;
    if(k == 1)
    {
        cout << "0\n";
    }
    else
    {
        cout << n - k << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
/*
 * sto Qingyu orz
 * 感谢真神sqy无私的教诲。膜时队者处处阿克，只因大师sqy在他背后。不膜大师者违背了真神的旨意，真神必将降下天谴,
 * 使其天天爆零
 * 我不由自主地膜拜真神sqy。
 * Author: RainAir
 * Time: 2019-10-16 16:11:09
 */
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define fi first
#define se second
#define U unsigned
#define P std::pair
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 5000+5;
const int ha = 1e9 + 7;

struct Edge{
    int to,nxt;
}e[MAXN<<1];
int head[MAXN],cnt,n;

inline void add(int u,int v){
    e[++cnt] = (Edge){v,head[u]};head[u] = cnt;
    e[++cnt] = (Edge){u,head[v]};head[v] = cnt;
}

int f[MAXN][MAXN],sz[MAXN],g[MAXN],tmp[MAXN];

inline void dfs(int v,int fa=0){
    sz[v] = 1;f[v][1] = 1;
    for(int i = head[v];i;i = e[i].nxt){
        if(e[i].to == fa) continue;
        dfs(e[i].to,v);
        FOR(j,0,sz[v]+sz[e[i].to]) tmp[j] = 0;
        FOR(x,0,sz[v]){
            FOR(y,0,sz[e[i].to]){
                (tmp[x+y] += 1ll*f[v][x]*f[e[i].to][y]%ha)%=ha;
            }
        }
        sz[v] += sz[e[i].to];
        FOR(j,0,sz[v]) f[v][j] = tmp[j];
    }
    int sm = 0;
    FOR(i,1,sz[v]) (sm += ha-1ll*f[v][i]*g[i]%ha) %= ha;
    f[v][0] = sm;
}

int main(){
    scanf("%d",&n);
    FOR(i,1,n-1){
        int u,v;scanf("%d%d",&u,&v);
        add(u,v);
    }
    g[0] = 1;
    FOR(i,2,n) g[i] = 1ll*g[i-2]*(i-1)%ha;
    dfs(1);
    printf("%d\n",(ha-f[1][0])%ha);
    return 0;
}


Measured memory_bytes: 96896
package main

import "fmt"

func main() {
	var a, b, c int
	_, _ = fmt.Scan(&a, &b, &c)
	if a >= b && a >= c {
		fmt.Println(b * c / 2)
	} else if b >= a && b >= c {
		fmt.Println(a * c / 2)
	} else {
		fmt.Println(a * b / 2)
	}
}

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

using namespace std;
using ll = long long int;
using ullong = unsigned long long;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i, a, b)  for(int i = (a); i < (b) ; i++)
#define pb push_back
#define SORT(v,n) sort(v, v+n)
#define ALL(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define int ll
int INF = 1e9;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
typedef pair<int, int> Vec2;
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };

signed main() {
	ios::sync_with_stdio(false);
	int a;
	cin >> a;
	cout << a * a << endl;
	return 0;
}


Measured memory_bytes: 256
def rec_sum(n, s, piv):
  if piv == 10 or piv > s:
    return 0
  if n == 1 and s < 10:
    return 1
  else:
    counter = 0
    for i in range(piv, 10):
      counter += rec_sum(n-1, s-i, i+1)
    return counter

while True:
  n, s = map(int, input().split())
  if n == 0 and s == 0:
    break
  print(rec_sum(n, s, 0))


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

int main(void) {
char str[1001];
int ans, pos;

while (scanf("%s", str), strcmp(str, "0")) {
ans = 0;
pos = 0;

while (str[pos] != '\0') {
ans += str[pos] - '0';
pos++;
}

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


Measured memory_bytes: 2056
#include <iostream>
#include <vector>
#include <bitset>
#include <functional>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <tuple>
using namespace std;

template <class T> void chmax(T &x, T y) {if(x<y) x=y;}
template <class T> void chmin(T &x, T y) {if(x>y) x=y;}



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

    int a[32]={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};
    int k; cin>>k; --k;
    cout << a[k] << "\n";
}

Measured memory_bytes: 256
// 適当に探索？ 最初のやつをSとして決め打ちして矛盾なければそれ、駄目だったらWでやってみて矛盾なければそれ、どっちも駄目ならお前はもう駄目だ 駄目
// 構築ってなんだ？
// 最後まで調べないとわからない系？
package main

import (
	"fmt"
	"strings"
)

func main() {
	var N int
	fmt.Scan(&N)
	var S string
	fmt.Scan(&S)
	tmp1, tmp2, tmp3, tmp4 := make([]string, N), make([]string, N), make([]string, N), make([]string, N)
	tmp1[0], tmp1[1] = "S", "S"
	tmp2[0], tmp2[1] = "S", "W"
	tmp3[0], tmp3[1] = "W", "W"
	tmp4[0], tmp4[1] = "W", "S"
	base := make([]string, N)
	for i, v := range []rune(S) {
		base[i] = string(v)
	}
	if ok, ret := program(base, tmp1); ok {
		fmt.Println(strings.Join(ret, ""))
	} else if ok, ret := program(base, tmp2); ok {
		fmt.Println(strings.Join(ret, ""))
	} else if ok, ret := program(base, tmp3); ok {
		fmt.Println(strings.Join(ret, ""))
	} else if ok, ret := program(base, tmp4); ok {
		fmt.Println(strings.Join(ret, ""))
	} else {
		fmt.Println(-1)
	}
}

func program(base []string, arr []string) (ok bool, ret []string) {
	for i := 1; i < len(arr)-1; i++ {
		s := base[i]
		if s == "o" {
			if arr[i] == "S" {
				arr[i+1] = arr[i-1]
			} else {
				if arr[i-1] == "S" {
					arr[i+1] = "W"
				} else {
					arr[i+1] = "S"
				}
			}
		} else {
			if arr[i] == "S" {
				if arr[i-1] == "S" {
					arr[i+1] = "W"
				} else {
					arr[i+1] = "S"
				}
			} else {
				arr[i+1] = arr[i-1]
			}
		}
	}
	flag := true
	if base[0] == "o" {
		if arr[0] == "S" {
			if arr[len(arr)-1] != arr[1] {
				flag = false
			}
		} else {
			if arr[len(arr)-1] == arr[1] {
				flag = false
			}
		}
	} else {
		if arr[0] == "S" {
			if arr[len(arr)-1] == arr[1] {
				flag = false
			}
		} else {
			if arr[len(arr)-1] != arr[1] {
				flag = false
			}
		}
	}
	if base[len(arr)-1] == "o" {
		if arr[len(arr)-1] == "S" {
			if arr[len(arr)-2] != arr[0] {
				flag = false
			}
		} else {
			if arr[len(arr)-2] == arr[0] {
				flag = false
			}
		}
	} else {
		if arr[len(arr)-1] == "S" {
			if arr[len(arr)-2] == arr[0] {
				flag = false
			}
		} else {
			if arr[len(arr)-2] != arr[0] {
				flag = false
			}
		}
	}
	return flag, arr
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int,int> P;
 
const int INF = 1001001001;
int dist[100005][3];


int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int> > to(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to[a].push_back(b);
    }
    int s,t;
    cin >> s >> t;
    s--;t--;
    rep(i,n)rep(j,3) dist[i][j] = INF;
    queue<P> q;
    q.push(P(s,0));
    dist[s][0] = 0;
    while (!q.empty()) {
        int v = q.front().first;
        int parity = q.front().second;
        q.pop();
        for (int u : to[v]){
            int np = (parity+1)%3;
            if (dist[u][np] != INF) continue;
            dist[u][np] = dist[v][parity]+1;
            q.push(P(u,np));
        }
    }
    int ans = dist[t][0];
    if (ans == INF) ans = -1;
    else ans /= 3;
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    int n,T;cin>>n>>T;
    V c(n),t(n);
    int res=INF;
    int tmp=INF;
    rep(i,n){
        cin>>c[i]>>t[i];
        if(t[i]<=T)tmp=c[i];
        res=min(res,tmp);
    }
    if(res==INF)cout<<"TLE"<<endl;
    else cout<<res<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int n;
  cin >> n;
  int ans = 0;
  int s, t, r;
  for(int top = 1; top < 10; top++){
    for(int bot = 1; bot < 10; bot++){
      s = 0;
      t = 0;
      r = 1;
      for(int i = 1; i <= n; i++){
        if(i == r*10){
          r *= 10;
        }
        if(i/r == top && i%10 == bot) s++;
        if(i/r == bot && i%10 == top) t++;
      }
      ans += s*t;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
xyz = [list(map(int,input().split())) for _ in range(n)]

res = -float('inf')
for i in range(8):
    tmp = []
    for l in xyz:
        t = 0
        if i&1:
            t += l[0]
        else:
            t -= l[0]
        if i&2:
            t += l[1]
        else:
            t -= l[1]
        if i&4:
            t += l[2]
        else:
            t -= l[2]
        tmp.append(t)
    tmp = sorted(tmp)
    res = max(res,sum(tmp[-m:]))
if m==0:
    print(0)
else:
    print(res)


Measured memory_bytes: 3316
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N; ll A[int(1e5 + 5)];

ld now = 1;
int Solve(){
  ll ans = 1;
  for (int i = 0; i < N; i++){
    now *= (ld)A[i];
    ans *= A[i];
    if (now > 1e18){
      cout << -1 << endl;
      return 0;
    }
  }

  if (ans > (ll)1e18) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}

int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", A + i);
    if (A[i] == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  Solve();

  return 0;
}


Measured memory_bytes: 4556
#include<iostream>
#include<map>
#include<vector>
using namespace std;
const int mod=1e9+7;

int modpow(long a,int p){
	long res=1;
	while(p){
		if(p&1) (res*=a)%=mod;
		(a*=a)%=mod;
		p>>=1;
	}
	return res;
}

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++) cin >> a[i];
	int x[n];
	x[0]=a[0];
	for(int i=1;i<n;i++) x[i]=a[i]^x[i-1];
	map<int,vector<int>> m;
	for(int i=0;i<n;i++) if(x[i]) m[x[i]].push_back(i);

	long ans=0;
	if(x[n-1]==0){
		int znum[n];
		znum[0]=(x[0]==0);
		for(int i=1;i<n;i++) znum[i]=znum[i-1]+(x[i]==0);
		long res=0;
		for(auto p:m){
			vector<int> v=p.second;
			long z=1,o=0;
			int cur=0;
			for(int i:v){
				long zero=znum[i]-znum[cur];
				long zn=(o*zero+z)%mod;
				long on=(zn+o)%mod;
				z=zn;
				o=on;
				cur=i;
			}
			(res+=o)%=mod;
		}
		(res+=modpow(2,znum[n-1]-1))%=mod;
		ans=res;
	}else{
		int y=x[n-1];
		long z=1,o=0;
		for(int i=0;i<n;i++){
			if(x[i]==0) (z+=o)%=mod;
			else if(x[i]==y) (o+=z)%=mod;
		}
		ans=z;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 37504
#include<bits/stdc++.h>
using   namespace   std;
#define N   100010
int a[N];
int main()
{
    int i,j,k,n,m,s;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    s=1000000007;
    for(i=m-1;i<n;i++)
        s=min(s,a[i]-a[i-m+1]);
    printf("%d\n",s);
    return  0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n;
  cin >> n;
  vector<int> height(n);
  for(int i=0;i<n;i++){
    cin >> height[i];
  }
  int count=0;
  int min,min_count;
  int ans=0;
  int back = n;
  while(true){
    if(height[count]==0){
      if(count==n-1){
        break;
      }
      count++;
      continue;
    }
    if(height[back-1]==0){
      back--;
      continue;
    }
    min = height[count];
    min_count=count;
    for(int i = count;i<back;i++){
      if(height[i]==0){
        min = 0;
        min_count=i;
        break;
      }
      if(min>=height[i]){
        min=height[i];
        min_count=i;
      }
    }

    if(count==min_count){
      for(int j = count;j<back;j++){
        height[j]-=min;
      }
      ans+=min;
      continue;
    }
    if(min==0){
      min = height[count];
      for(int j = count;j<min_count;j++){
        if(min>=height[j]){
          min=height[j];
        }
      }
      for(int k = count;k<min_count;k++){
        height[k]-=min;
      }
      ans+=min;
      continue;
    }else{
      for(int j = count;j<back;j++){
        height[j]-=min;
      }
      ans+=min;
      continue;
    }
  }

  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 2e5 + 20 ;
int n , a[N] ;
int ans ;
bool dead[N] ;

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

	cin >> n ;

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

	sort(a , a + n) ;

	for (int i = n - 1 ; i > 0 ; i --) {
		if (dead[i]) continue ;
		
		int x = a[i] , p = 1 ;

		while (p <= x) p *= 2 ;

		int y = p - x ;

		int low = -1 , high = i - 1 ;

		while (high - low > 1) {
			int mid = (low + high) >> 1 ;

			if (a[mid] < y || (a[mid] == y && dead[mid])) low = mid ;
			else high = mid ;
		}

		if (a[high] == y && !dead[high]) {
			ans ++ ;
			dead[high] = 1 ;
		}
	}

	cout << ans << '\n' ;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	ll n; cin>>n;
	ll ans=0;
	ll cnt=0;
	ll b=-1;
	rep(i,0,n){
		ll a; cin>>a;
		if(i==0){
			b=a;
			continue;
		}
		if(b<a){
			chmax(ans,cnt);
			cnt=0;
		}
		else cnt++;
		b=a;
		//cout<<"cnt:"<<cnt<<endl;
	}
	chmax(ans,cnt);
	cout<<ans<<endl;
		
	return 0;
}

Measured memory_bytes: 3512
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
#include<queue>
#include<algorithm>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    priority_queue<int> pq;
    int n = 0;
    cin >> n;
    vector<int> v;
    int v0;
    REP(i, n) {
        int vi;
        cin >> vi;
        v.push_back(vi);
    }
    sort(v.begin(), v.end(), greater<int>());
    v0 = v[0];
    v.erase(v.begin());
    pq.push(v0);
    long long ans = 0;
    for (int vi : v) {
        ans += pq.top();
        pq.pop();
        pq.push(vi);
        pq.push(vi);
    }
    cout << ans << endl;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,ans;
    ll k,cnt=0;
    cin >> n >> k;
    vector<ll> v(1e5+1);
    for(int i = 0;i < n;i ++){
        int a,b;
        cin >> a >> b;
        v[a] += b;
    }
    for(int i = 1;i < 1e5+1;i ++){
        if(cnt+v[i]<k) cnt+=v[i];
        else {ans = i;break;}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll Maxi = 55555;
ll N;
vl prm;

int main(){
  cin >> N;

  vl furui(Maxi + 1, 1);
  furui[0] = 0;
  furui[1] = 0;

  rep(i, Maxi){
    if(furui[i] == 0) continue;

    prm.push_back(i);

    ll j = 2*i;
    while(j < Maxi + 1){
      furui[j] = 0;
      j += i;
    }
  }

  rep(i, prm.size()){
    if(prm[i] % 5 == 1){
      cout << prm[i] << ' ';
      N--;
    }
    if(N == 0){
      cout << "\n";
      return 0;
    }
  }
  
  return 0;
}


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

int h,w;
const int INF = 1e9 + 7;
vector<string> a;
vector<vector<int>> dp;

int rec(int i,int j){
  if(dp[i][j]!=-1) return dp[i][j];
  if(a[i][j]=='#' || i>=h || j>=w) return 0;
  if(a[i+1][j]=='.' && a[i][j+1]=='.') return dp[i][j] = ((rec(i+1,j) + rec(i,j+1)))%INF;
  return dp[i][j] = max(rec(i+1,j),rec(i,j+1));
}


int main(){
  cin >> h >> w;
  for (int i = 0; i < h; i++)
  {
    string s;
    cin >> s;
    s+="#";
    a.push_back(s);
  }
  a.push_back(string(w,'#'));
  dp.assign(h+1,vector<int>(w+1,-1));
  dp[h-1][w-1]=1;
  rec(0,0);
  cout << dp[0][0] << endl;
}

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

const int nmaxval = 8;
bool g[nmaxval][nmaxval];

int DFS(int p, int N, bool visited[nmaxval]) {
  bool allvisited = true;
  for (int i=0; i<N; i++)
    if (visited[i] == false) allvisited = false;

  if (allvisited) {
    return 1;
  } else {
    int ret = 0;
    for (int i=0; i<N; i++) {
      if (g[p][i] == false) continue;
      if (visited[i]) continue;

      visited[i] = true;
      ret += DFS(i, N, visited);
      visited[i] = false;
    }
    return ret;
  }
}

int main() {
  int N, M;
  cin >> N >> M;
  for (int i=0; i<M; i++) {
    int a, b;
    cin >> a >> b;
    g[a-1][b-1] = g[b-1][a-1] = true;
  }

  bool v[nmaxval];
  for (int i=1; i<N; i++) v[i] = false;
  v[0] = true;

  cout << DFS(0, N, v) << endl;

  return 0;
}


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

int main() {
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  int x3=x2+y1-y2;
  int y3=y2+x2-x1;
  int x4=x1+y1-y2;
  int y4=x2-x1+y1;
  cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4<<endl;
}
    
        
      
  



Measured memory_bytes: 256
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

a = [x for x in range(1, n+1)]

import itertools

b = list(itertools.permutations(a))
for num, x in enumerate(b):
    if x == p:
        res1 = num
    if x == q:
        res2 = num
print(abs(res1 - res2))

Measured memory_bytes: 8052
import math
a, b, C = map(int, raw_input().split())
S = (a * b * math.sin(math.radians(C))) / 2
c = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(C)))
print("%f" % (S))
print("%f" % ( a + b + c))
print("%f" % ((S * 2) / a))

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

bool check(int n){
    if(n == 1) return false;
    for(int i = 2;i <= sqrt(n);++i){
        if(n%i == 0)return false;
    }
    return true;
}

int main(){
    int q; cin >> q;
    vector<int> dp(100001);
    dp[0] = 0;
    for(int i = 1;i < 100001;i++){
        if(i%2 == 1 && check(i) && check((i+1)/2)) dp[i] = dp[i-1]+1;
        else dp[i] = dp[i-1];
    }
    rep(i,q){
        int l,r; cin >> l >> r;
        cout << dp[r]-dp[l-1] << endl;
    }
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
using namespace std;
int main() {
	int N, nxt;
	scanf("%d", &N);
	int occ[N];
	fill_n(occ, N, 0);
	long long int ans = 1;
	for (int i = 0; i < N; ++i) {
		scanf("%d", &nxt);
		if (nxt == 0) ans = ans * (3 - occ[0]);
		else ans = ans * (occ[nxt - 1] - occ[nxt]);
		if (ans < 0 || ++occ[nxt] > 3) {
			printf("0");
			return 0;
		}
		ans %= 1000000007;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(100000)  # RecursionError対策

def func(n):
    if n==0:
        return 0 # 終端条件
    if memo[n] != -1:
        return memo[n] # 探索済み

    res = n

    for i in range(1,n+1):
        pow6 = 6 ** i
        if pow6 > n:
            break
        res = min(res, func(n-pow6)+1)

    for i in range(1,n+1):
        pow9 = 9 ** i
        if pow9 > n:
            break
        res = min(res, func(n-pow9)+1)

    memo[n] = res
    return res


N = int(input())

max_n = 110000
memo = [-1] * max_n
ans = func(N)
print(ans)


Measured memory_bytes: 24972
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<cctype>
using namespace std;
#define fr first
#define sc second
typedef pair<int,int> Pt;
typedef pair<Pt ,int> P;
#define MAX 1000001
bool SOSU[MAX]={true,true};
int main(){
  for(int i=2;i<MAX;i++){
    if(!SOSU[i]){
      for(int j=i+i;j<MAX;j+=i){
        SOSU[j] = true;
      }
    }
  }
  int a,b,n;
  while(cin >> a >> b >> n && a){
    int cnt = 0,i = a;
    for(;i<MAX;i+=b){
      if(!SOSU[i]) cnt++;
      if(cnt == n) break;
    }
    cout << i << endl;
  }
}

Measured memory_bytes: 2136