akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <map>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

int N, M;
const int MAX_N = 100010;
const int MAX_M = 100010;
int a[MAX_M], b[MAX_M];

std::vector<int> Edge[MAX_M];
bool edge_used[MAX_M];
bool visited[MAX_N];
std::map<std::pair<int, int>, int> edge_map;

bool search_loop(int n, int from, std::vector<int>& path) {
    path.push_back(n);
    if (visited[n]) {
        return true;
    }
    visited[n] = true;
    for (int i = 0; i < Edge[n].size(); i++) {
        int e = Edge[n][i];
        assert(n == a[e] || n == b[e]);
        int next = (n == a[e]) ? b[e] : a[e];
        if (!edge_used[e] && next != from) {
            if (search_loop(next, n, path)) {
                return true;
            }
        }
    }
    visited[n] = false;
    path.pop_back();
    return false;
}

bool process_loop(int n) {
    std::vector<int> path;
    if (search_loop(n, -1, path)) {
        for (auto v : path) {
            visited[v] = false;
            //std::cout << v << " ";
        }
        //std::cout << std::endl;
        for (int i = path.size() - 1; 1 <= i; i--) {
            int min = std::min(path[i], path[i-1]);
            int max = std::max(path[i], path[i-1]);
            int e = edge_map[std::pair<int, int>({min, max})];
            edge_used[e] = true;
            if (path[i-1] == path.back()) {
                break;
            }
        }
        return true;
    }
    return false;
}

int main(int argc, char **argv) {
    std::cin >> N >> M;

    for (int i = 1; i <= M; i++) {
        std::cin >> a[i] >> b[i];
    }

    for (int i = 1; i <= M; i++) {
        edge_used[i] = false;
        int min = std::min(a[i], b[i]);
        int max = std::max(b[i], a[i]);
        edge_map[std::pair<int, int>({min, max})] = i;

        Edge[a[i]].push_back(i);
        Edge[b[i]].push_back(i);
    }

    int cnt = 0;
    for (int i = 1; i <= N; i++) {
        while(process_loop(i)) {
            cnt++;
            //if (cnt == 3) { break; }
        }
        //if (cnt == 3) { break; }
    }

    //std::cout << cnt << std::endl;

    for (int i = 1; i <= M; i++) {
        if (!edge_used[i]) {
            //std::cout << "edge_err:" << i << std::endl;
            std::cout << "No" << std::endl;
            return 0;
        }
    }

    if (3 <= cnt) {
        std::cout << "Yes" << std::endl;
        return 0;
    }

    int add = 0;
    for (int i = 1; i <= N; i++) {
        add += Edge[i].size() - 2;
    }

    if (6 <= add) {
        std::cout << "Yes" << std::endl;
        return 0;
    }

    std::cout << "No" << std::endl;
    return 0;

}

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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=Int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;

  Int ans=0;
  for(Int a=1;a<n;a++)
    for(Int b=1;a*b<n;b++)
      ans++;
  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 3660
n,k=map(int,input().split())
am_0=[]
am_k2=[]

if k%2==0:
  for i in range(1,n+1):
    if i%k==0:
      am_0.append(i)
    
    elif i%k==(k//2):
      am_k2.append(i)
  print(len(am_0)**3+len(am_k2)**3)
  
else:
  print(pow((n//k),3))
        

Measured memory_bytes: 16848
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;


lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {


	lli N, A[5];
	cin >> N;
	for (int i = 0; i < 5; i++)
		cin >> A[i];

	cout.precision(18);
	COUT(ceil((double)N / (*min_element(A,A+5))) + 4);


	return 0;
}

Measured memory_bytes: 256
import sys
import math
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
N = len(s)
n = N//2

ans = 0
for i in range(n):
  if s[i] != s[N-i-1]:
    ans += 1
print(ans)

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

int main(){
	double mountain, max = -1, mini = -1;
	while (scanf("%lf", &mountain) != EOF){
		if (max == -1 || mountain > max) max = mountain;
		if (mini == -1 || mountain < mini) mini = mountain;
	}
	printf("%.1f\n", max - mini);
	return 0;
}

Measured memory_bytes: 1236
S = open(0).read().strip('\n').split(' ')
S = [int(s) for s in S]
even = 0 if  S[0]==1 else S[0]*(S[0]-1)/2
odd = 0 if  S[0]==1 else S[1]*(S[1]-1)/2
print(int(even+odd))

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

const int N = 2e5 + 5;

int n;
int a[N];
int fw[N];
vector<int> vec;

void upd(int p) {
	p += N / 2;
	for (; p < N; p += p & -p) fw[p]++;
}

int get(int p) {
	int ret = 0;
	p += N / 2;
	for (; p > 0; p -= p & -p) ret += fw[p];
	return ret;
}

bool check(int mid) {
	memset(fw, 0, sizeof fw);
	int sum = 0; upd(sum);
	long long ans = 0;
	for (int i = 1; i <= n; ++i) {
		if (a[i] > mid) sum--;
		else sum++;
		ans += get(sum - 1);
		upd(sum);
	}
	return ans >= 1ll * n * (n + 1) / 4 + 1;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		vec.push_back(a[i]);
	}
	sort(vec.begin(), vec.end());
	vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
	for (int i = 1; i <= n; ++i) {
		a[i] = lower_bound(vec.begin(), vec.end(), a[i]) - vec.begin() + 1;
	}
	
	int l = 1, r = vec.size();
	while (l < r) {
		int mid = l + r >> 1;
		if (check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << vec[l - 1] << '\n';
}

Measured memory_bytes: 1912
input = *$<
N, M, = input.shift.split.map(&:to_i)

Tr = N.times.map{|i|
	[0]*(N-i)
}
m = M
until (m-=1) == -1
	l, r = input.shift.split.map(&:to_i)
	Tr[l-1][r-l] += 1
end
i = N-1
until (i-=1) == -1
	j = 0
	Tr[i][j] += Tr[i][j-1] until (j+=1) == N-i
	j = 0
	Tr[i][j] += Tr[i+1][j-1] until (j+=1) == N-i
end

p *input.map{|ln|
	l, r = ln.split.map(&:to_i)
	Tr[l-1][r-l]
}


Measured memory_bytes: 35580
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<ll> x(n),a(n);
    rep(i, n)
    {
        cin >> x[i];
        a[i] = x[i];
    }
    sort(a.begin(), a.end());
    rep(i, n){
        if (x[i] <= a[n/2-1]) {
            cout << a[n / 2] << endl;
        } else {
            cout << a[n / 2 - 1] << endl;
            ;
        }
    }
    return 0;
}

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



int main(){
	int n;
	while(cin>>n&&n){
		int s=0;
		for(int i=0;i<n/4;i++){
			int a;
			cin>>a;
			s+=a;
		}
		cout<<s<<endl;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define SUM(x) accumulate(ALL(x), 0)
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000

ll five(ll &i) {
  return i * i * i * i * i;
}

int main()
{
  ll x; cin >> x;
  bool ans = false;
  REP(i, 10000) {
    ll f1 = five(i);
    REP(j, 10000) {
      ll f2 = five(j);
      if (five(i) + five(j) == x) {
        cout << i << " " << j * (-1) << endl;
        ans = true;
      } else if (five(i) - five(j) == x) {
        cout << i << " " << j << endl;
        ans = true;
      }
    }
    if (ans) break;
  }
  return 0;
}


Measured memory_bytes: 3636
N, K = map(int, input().split())
A = list(map(int, input().split()))
B = [1]
C = [1] + [0] * (N - 1)
i = 0

while C[A[i] - 1] == 0:
    B.append(A[i])
    C[A[i] - 1] = 1
    i = A[i] - 1

ans = 0
for j in range(len(B)):
    if B[j] == A[i]:
        ans += j

if (len(B) - ans != 0) and (K - ans > 0):
    ans += (K - ans) % (len(B) - ans)
elif K - ans <= 0:
    ans = K


print(B[ans])

Measured memory_bytes: 32276
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
int n, ans = 0;

int main() {
//    freopen("in.in", "r", stdin);
    cin >> n;
    cout << n * n * n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

const double P=1e9;

int main(){
  int N;
  cin>>N;
  vector<ll> A(N+1,0),T(N+1,0);
  rep(i,N) cin>>T[i+1]>>A[i+1];

  int Q;
  cin>>Q;
  vector<ll> L(Q),R(Q);
  rep(i,Q) cin>>L[i]>>R[i];

  vector<double> sum(N+1);
  sum[0]=P;
  for(int i=1;i<=N;i++) sum[i]=sum[i-1]*(10-A[i])/10;

  vector<double> ans(Q);
  rep(i,Q){
    int l=lower_bound(T.begin(),T.end(),L[i])-T.begin();
    int r=lower_bound(T.begin(),T.end(),R[i])-T.begin();

    l--;r--;
    ans[i]=P*sum[r]/sum[l];
  }

  rep(i,Q) cout<<fixed<<setprecision(10)<<ans[i]<<endl;



  return 0;
}



Measured memory_bytes: 7592
#include <algorithm>
#include <iostream>

using namespace std;

int n;
int A, B, C;
int D[100];
int main() {
    cin >> n;
    cin >> A >> B;
    cin >> C;
    for (int i = 0; i < n; i++) {
        cin >> D[i];
    }

    
    sort(D, D + n);
    reverse(D, D + n);
    
    int max,cal=C,wa;
    wa=C/A;
    max=wa;
    for (int i = 0; i < n; i++) {
    	cal+=D[i];
    	A+=B;
    	wa=cal/A;
    	if(wa>max) max=wa;
    }
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <climits>
#include <bitset>
#include <cassert>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

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

string s;
int i;

struct result{
	int value, useope;
};

result expr();

int num_ok(int x){
	return 0 <= x && x < (1 << 10);
}

result num(){
	if (s[i] != '0' && s[i] != '1') throw "num";
	result res = { 0, 0 };
	while (s[i] == '0' || s[i] == '1'){
		res.value = res.value * 2 + s[i] - '0';
		++i;
	}
	if (!num_ok(res.value)) throw "num_overflow";
	return res;
}

// (expr) || num
result term(){
	result res = { -1, 0 };
	if (s[i] == '('){
		++i;
		res = expr();
		if (!res.useope) throw "term";
		if (s[i] != ')') throw "term";
		++i;
	}
	else if (s[i] == '0' || s[i] == '1'){
		res = num();
	}
	else{
		throw "term";
	}
	res.useope = false;
	return res;
}

// term | term * factor
result factor(){
	result res = term();
	while (s[i] == '*'){
		i++;
		res.value *= term().value;
		res.useope = true;
		if (!num_ok(res.value)) throw "num_overflow";
	}
	return res;
}

// factor + expr
result expr(){
	result res = factor();
	while (s[i] == '+' || s[i] == '-'){
		if(s[i] == '+'){
			i++;
			res.value += factor().value;
		}
		else {
			i++;
			res.value -= factor().value;
		}
		res.useope = 1;
		if (!num_ok(res.value)) throw "expr_overflow";
	}
	if (s[i] != '$' && s[i] != ')') throw "expr";
	return res;
}

int parse(){
	i = 0;
	int res = expr().value;
	if (s[i] != '$') throw "parse";
	return res;
}

int n;
int pos[10];

int dfs(int i){
	if (i == n){
		int res = 0;
		try{
			res = parse();
		}
		catch ( ... ){
			res = -1;
		}
		return res;
	}

	int res = -1;
	rep(j, 7){
		s[pos[i]] = "01+-*()"[j];
		res = max(res, dfs(i + 1));
	}
	return res;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout.setf(ios::fixed);
	cout.precision(20);

	while (cin >> s){
		n = 0;
		s += "$$$";
		rep(i, s.size()) if (s[i] == '.') pos[n++] = i;

		cout << dfs(0) << endl;
	}
}

Measured memory_bytes: 1252
#include <stdio.h>

int main(){
    int n;

    scanf("%d", &n);

    int H[n];
    int count = 0, max = 0;
    for(int i = 0; i < n; i++){
        scanf("%d", &H[i]);
      
        if(i != 0 && H[i-1] >= H[i]){
          count++;  
        } else {
            if(max < count){
                max = count;
            }
            count = 0;
        }
    }
	if(max < count){
      max = count;
    }
    printf("%d", max);

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  string s[n],t[m];
  rep(i,n) R s[i];
  rep(i,m) R t[i];
  rep(i,n-m+1)rep(j,n-m+1) {
    bool f=1;
    rep(k,m)rep(l,m)if(s[i+k][j+l]!=t[k][l]) f=0;
    if(f) {
      pr("Yes");
      return;
    }
  }
  pr("No");
}

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


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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define mp make_pair
#define F first
#define S second


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(long long* a,long long n,long long val){
	for(long long i=0;i<n;i++)
		a[i]=val;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll t=1,i,j;
	ll n;
	cin>>n;
	ll a;
	ll c[62]={0};
	rep(i,0,n){
	    cin>>a;
	    for(j=1;j<=a;j=j<<1){
	        if(j&a)
	            c[(ll)log2(j)]++;
	    }
	}ll ans=0,k;
	rep(i,0,62){
	    k=c[i]*(n-c[i]);
	    k%=M;
	    ans+=((k*((ll)pow(2,i)%M))%M);
	    ans%=M;
	}
	
/*	rep(i,0,n){
	    cin>>a[i];
	}
	ll c=0,k,ans=0;
	rep(j,0,62){
	    c=0;
	    rep(i,0,n){
	        if(a[i]&(ll)pow(2,j)){
	            c++;
	        }
	    }
	   // if(c)
	        //cout<<(1<<j)<<endl;
	    k=c*(n-c);
	    k%=M;
	    //cout<<k<<endl;
	    ans+=((k*((ll)pow(2,j)%M))%M);
	    //cout<<ans<<endl;
	    ans%=M;
	}*/
	
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import fractions

N, X = map(int, input().split())
x = list(map(int, input().split())) + [X]
x.sort()

dist = []
for i in range(N):
    dist.append(x[i+1] - x[i])

g = dist[0]

for i in range(N-1):
    g = fractions.gcd(g, dist[i+1])

print(g)


Measured memory_bytes: 16284
ln = split(readline())
n = parse(Int, ln[1])
k = parse(Int, ln[2])
arr = zeros(Int, 100000)
for i in 1:n
    ln = split(readline())
    a = parse(Int, ln[1])
    b = parse(Int, ln[2])
    arr[a] += b
end
cnt = 0
for ans in 1:100000
    cnt += arr[ans]
    if k <= cnt
        println(ans)
        break
    end
end

Measured memory_bytes: 169860
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n,i,cnt=0;
    cin >> n;
    vector<int> a(n);
    for(i=0;i<n;i++) cin >> a[i];
    for(i=0;i<n;i++){
        if(a[i]!=i+1) cnt++;
    }
    if(cnt<=2) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  int a,b;
  cin >> a >> b;
  if(a%3==0 || b%3 == 0 || (a+b)%3 == 0)
    P("Possible");
  else
    P("Impossible");

  ret 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << endl;
	

}



Measured memory_bytes: 3680
#include <iostream>

using namespace std;

typedef long long ll;

const int MAX_N = 60;

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

ll dp[MAX_N][2*MAX_N*MAX_N] = {0};

int main(int argc, char const *argv[])
{
	int n, a, x[MAX_N]={0}, y[MAX_N]={0};
	cin >> n >> a;
	int maxX = a;
	y[0] = x[0] - a;
	for (int i = 0; i < n; ++i) {
		cin >> x[i+1];
		maxX = max(maxX, x[i+1]);
		y[i+1] = x[i+1] - a;
	}

	EREP(j, n){
		EREP(t,2*n*maxX){
			if (j==0 && t==n*maxX) dp[j][t] = 1;
			if (j>=1 && (t-y[j]<0||t-y[j]>2*n*maxX)) dp[j][t] = dp[j-1][t];
			if (j>=1 && 0<=t-y[j] && t-y[j]<=2*n*maxX) dp[j][t] = dp[j-1][t] + dp[j-1][t-y[j]];
		}
	}

	cout << dp[n][n*maxX]-1 << endl;
	return 0;
}

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

def runLengthEncoding(s:str) -> list:
    """
    ランレングス圧縮します。リスト内に(文字,個数)の形でカウントを収納して
    Returnします。見ての通りO(N)です。
    """
    l = []
    N = len(s)
    count = 1
    char = s[0]
    for i in range(1, N):
        if char != s[i]:
            tmp = (char, count)
            l.append(tmp)

            char = s[i]
            count = 1

        elif char == s[i]:
            count += 1

    l.append((char, count))

    return l


lre = runLengthEncoding(S)

if len(lre) == 2:
    print(N-1)
    exit()

else:
    n = len(lre) // 2
    ans = None
    if K >= n:
        ans = N-1
    else:
        groups = len(lre) - 2*K

        ans = (N-1) - groups + 1

    print(ans)


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

num = 1
ans = 0

if 1 not in A:
    print(-1)
    exit()

for i in range(n):
    a = A[i]
    if a == num:
        num += 1
        continue
    else:
        ans += 1
print(ans)


Measured memory_bytes: 77516
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <numeric>    // accumulate
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  int H, W;
  char tmp;
  cin >> H >> W;
  vector<vector<bool>> a(H, vector<bool>(W, false));
  vector<vector<ll>> c(H, vector<ll>(W, 0));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> tmp;
      if (tmp == '.') {
        a[i][j] = true;
      } else {
        a[i][j] = false;
      }
    }
  }
  c[0][0] = 1;

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i < H - 1 && a[i + 1][j])
        c[i + 1][j] = (c[i + 1][j] + c[i][j]) % 1000000007;
      if (j < W - 1 && a[i][j + 1])
        c[i][j + 1] = (c[i][j + 1] + c[i][j]) % 1000000007;
    }
  }
  cout << c[H - 1][W - 1] << endl;
}


Measured memory_bytes: 10996
// 1_5_B
#include<stdio.h>

int main(void)
{
	int height, width, H, W;
	while(1){
		scanf("%d %d", &H, &W);
		if(H == 0 && W == 0){
			break;
		}

		for(height = 0; height < H; height++){
			for(width = 0; width < W; width++){
				if(height == 0 || height == H-1 || width == 0 || width == W-1){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
'use strict'
const inputs = require('fs').readFileSync(0, 'utf8').split('\n')
const N = parseInt(inputs[0], 10)
const K = parseInt(inputs[1], 10)
if (N === 1) console.log(2)
else if (K === 1) console.log(1+N)
else if (K === 2) console.log(2+2*(N-1))
else if (N === 2) console.log(4)
else if (K <= 4) console.log(4+K*(N-2))
else if (N === 3) console.log(8)
else if (K <= 8) console.log(8+K*(N-3))
else console.log(16+K*(N-4))

Measured memory_bytes: 7372
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define rep(i,n) for (int i=0;i<(n);++i)
#define rep2(i,a,b) for (int i=(a);i<(b);++i)
#define rrep(i,n) for (int i=(n)-1;i>=0;--i)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i)
#define range(i,a,b,c) for (int i=a;((c>0)?i<b:i>b);i+=c) 
// #define range(a,b,c) (\
// #if c > 0 \					
// for (int i = a; i < b; i += c) \
// #endif)

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

ll a, b, c, d;

void solve() {
  cin >> a >> b >> c >> d;
  cout << max(a*b, c*d) << endl;
}

int main() {
  int T = 10;
  rep(i, T) {
  	char s[MAX];
  	if (scanf("%s", s) == EOF) break;
  	rrep(i, strlen(s)) {
  	  ungetc(s[i], stdin);
  	}
  	solve();
  }
  return 0;
}


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

const int LIMIT = 50;
int N, M;
int lefts[LIMIT], rights[LIMIT];
bool adj[LIMIT][LIMIT];  ///< adjacency matrix.
bool visited[LIMIT];

void DFS(int node) {
  visited[node] = true;
  for (int next = 0; next < N; ++next) {  // For each node.
    if (adj[node][next] == false)  // Not connected.
      continue;
    if (visited[next] == true)  // Already visited.
      continue;
    DFS(next);
  }
}

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {  // For each edge.
    int left, right;
    cin >> left >> right;
    lefts[i] = --left;
    rights[i] = --right;
    adj[left][right] = true;  // Connects.
    adj[right][left] = true;
  }
  int n_bridges = 0;
  for (int i = 0; i < M; ++i) {  // For each edge.
    int left = lefts[i], right = rights[i];
    adj[left][right] = false;  // Cuts.
    adj[right][left] = false;
    for (int j = 0; j < N; ++j)  // Initializes.
      visited[j] = false;
    DFS(0);  // Derives visited or not.
    for (int j = 0; j < N; ++j) {  // For each node.
      if (!visited[j]) {  // Not a spanning tree.
        ++n_bridges;
        break;
      }
    }
    adj[left][right] = true;  // Connects.
    adj[right][left] = true;
  }
  cout << n_bridges << endl;
}


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

int main(void) {
  int N, M;
  cin >> N >> M;

  ll L;
  cin >> L;

  auto g = make_vec<ll>(N, N);
  auto ans = make_vec<ll>(N, N);
  fill_v(g, longinf);
  fill_v(ans, longinf);

  REP(i, M){
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;

    g[a][b] = c;
    g[b][a] = c;
  }

  REP(i, N) REP(j, N) if(i == j) g[i][j] = 0;
  REP(k, N) REP(i, N) REP(j, N) chmin(g[i][j], g[i][k] + g[k][j]);

  REP(i, N) REP(j, N) {
    if(i == j) ans[i][j] = 0;
    else if(g[i][j] <= L) ans[i][j] = 1;
  }
  REP(k, N) REP(i, N) REP(j, N) chmin(ans[i][j], ans[i][k] + ans[k][j]);
 

  int Q;
  cin >> Q;
  REP(i, Q){
    int s, t;
    scanf("%d %d", &s, &t);
    s--;t--;

    cout << (ans[s][t] == longinf ? -1 : ans[s][t] - 1) << endl;
  }

  return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
#include <memory.h>

int count[100];
void solve(int depth, int card[][2], int n, int total, int goal[], int gn) {
	int i;
	if(depth == n) {
		for(i=0;i<gn;i++) {
			if(total == goal[i])
				count[i]++;
		}
		return;
	}
	
	for(i=0;i<=card[depth][1];i++) {
		solve(depth+1, card, n, total + card[depth][0] * i, goal, gn);
	}
}

int main(void) {
	int n, g;
	int i;
	int goal[100];
	int j[1001];
	int card[1001][2];
	while(1) {
		memset((char*)count, 0x00, sizeof(count));
		scanf("%d\n", &n);
		if(n==0) break;
		for(i=0;i<n;i++) {
			scanf("%d %d\n", &card[i][0], &card[i][1]);
		}
		scanf("%d\n", &g);
		for(i=0;i<g;i++) {
			scanf("%d\n", &goal[i]);
		}
		solve(0, card, n, 0, goal, g);	
		for(i=0;i<g;i++) {
			printf("%d\n", count[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 604
from collections import deque
INF = 10**12+7
N,M,R = map(int,input().split())
r = list(map(str,input().split()))
d = [[INF]*(N+1) for _ in range(N+1)]
for _ in range(M):
    A,B,C = map(int,input().split())
    d[A][B] = C
    d[B][A] = C
for i in range(1,N+1):
    d[i][i] = 0
for k in range(N+1):
    for i in range(N+1):
        for j in range(N+1):
            d[i][j] = min(d[i][j],d[i][k] + d[k][j])
#print(d)
ans = INF
que = deque([])
for i in r:
    que.append([i])
while len(que) != 0:
    p = que.popleft()
    if len(p) == R:
        #print(p)
        val = 0
        for i in range(1,R):
            val += d[ int(p[i-1])][int(p[i])]
        ans = min(ans,val)
    else:
        for i in r:
            if not i in p:
                que.append(p+[i])
print(ans)

Measured memory_bytes: 86428
n, time = [int(_) for _ in input().split()]
tmp = 1001
output = 0

for i in range(n):
    c, t = [int(_) for _ in input().split()]
    if c < tmp and t <= time:
        tmp = c
        output = c

if output == 0:
    print("TLE")

else:
    print(output)


Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

#define INF 200000000

using namespace std;

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

vector<int> G[10000];
list<int> L;
bool checked[10000];

void visit(int n)
{
	if (!checked[n])
	{
		checked[n] = true;
		for (auto& m : G[n])
		{
			visit(m);
		}
		L.push_front(n);
	}
}

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

	int V, E;
	scanf("%d %d", &V, &E);

	for (int i = 0; i < E; i++)
	{
		int u, v;
		scanf("%d %d", &u, &v);

		G[u].push_back(v);
	}

	for (int i = 0; i < V; i++)
	{
		visit(i);
	}

	for (auto& n : L)
	{
		printf("%d\n", n);
	}
	return 0;
}


Measured memory_bytes: 4172
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int H,W,N;
string s,m[1000];
int dis[4][1000][1000];
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int nxt[4][1<<20];
main()
{
	while(cin>>H>>W>>N,H)
	{
		cin>>s;
		int sx,sy;
		for(int i=0;i<H;i++)
		{
			cin>>m[i];
			for(int j=0;j<W;j++)for(int r=0;r<4;r++)dis[r][i][j]=2*N;
			for(int j=0;j<W;j++)
			{
				if(m[i][j]=='S')
				{
					sx=i;
					sy=j;
				}
			}
		}
		int nowr=0;
		for(int i=0;i<N;i++)nowr+=s[i]=='L'?1:-1;
		nowr=(nowr%4+4)%4;
		int nowd[4];
		for(int r=0;r<4;r++)nowd[r]=nxt[r][N]=r==nowr?N:2*N;
		for(int i=N;i--;)
		{
			nowr-=s[i]=='L'?1:-1;
			nowr=(nowr%4+4)%4;
			nowd[nowr]=i;
			for(int r=0;r<4;r++)nxt[r][i]=nowd[r];
		}
		dis[0][sx][sy]=0;
		priority_queue<pair<pair<int,int>,pair<int,int> > >P;
		P.push({{0,0},{sx,sy}});
		bool flag=false;
		while(!P.empty())
		{
			int d=-P.top().first.first;
			int nr=P.top().first.second;
			int x=P.top().second.first;
			int y=P.top().second.second;
			P.pop();
			if(dis[nr][x][y]<d)continue;
			if(m[x][y]=='G')
			{
				flag=true;
				break;
			}
			for(int r=0;r<4;r++)
			{
				int tx=x+dx[r],ty=y+dy[r];
				if(tx<0||ty<0||tx>=H||ty>=W||m[tx][ty]=='#'||dis[r][tx][ty]<=nxt[r][d])continue;
				dis[r][tx][ty]=nxt[r][d];
				P.push({{-nxt[r][d],r},{tx,ty}});
			}
		}
		cout<<(flag?"Yes":"No")<<endl;
	}
}


Measured memory_bytes: 21740
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int a,b;cin>>a>>b;
  cout<<a*b<<endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>

int main(int argc, char const* argv[])
{
	int n;
	std::cin >> n;

	for (int i = 1; i <= n; i++) {
		int x = i;
		if (x % 3 == 0) {
			std::cout << " " << i;
		} else {
			do {
				if (x % 10 == 3) {
					std::cout << " " << i;
					break;
				}
				x /= 10;
			} while(x);
		}
	}
	std::cout << std::endl;
	return 0;
} 


Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

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

int main()
{
	int n;
	
	while(cin >> n,n)
	{
		int un,tp;
		if(isprime(n))
		{
			cout << 0 << endl;
		}
		else
		{
			for(int i = 1;;i++)
			{
				if(isprime(n-i))
				{
					un = n-i;
					break;
				}
			}
			
			for(int i = 1;;i++)
			{
				if(isprime(n+i))
				{
					tp = n+i;
					break;
				}
			}
//			cout << un << ' ' << tp << endl;
			cout << tp - un << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3108
fun main(args: Array<String>) {
    var (N,a,b) = readLine()!!.split(" ").map(String::toInt)
    var ans = 0
    (1..N).map{ idx->
        idx.toString().map{
            it.toString().toInt()
            }.sum().let{
                when{
                    a<=it && it<=b -> idx
                    else -> 0
                }
            }
    }.sum().let{
        print(it)
    }
}


Measured memory_bytes: 41352
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll INF=1LL<<60;
 
 
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int r=0,g=0,b=0;
	rep(i,n){
		if(s[i]=='R')r++;
		if(s[i]=='G')g++;
		if(s[i]=='B')b++;
	}
	ll all=r*g*b,part=0;
	rep(i,n){
		int k=1;
		while(1){
			if(2*k+i<n){
				if(s[i]!=s[k+i]&&s[k+i]!=s[2*k+i]&&s[i]!=s[2*k+i]){
					part++;
					//cout << i << " , "<<k<< endl;
				}
			}
			else break;
			k++;
		}
	}
	cout << all-part;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    vector<int> v(N);
    int cnt[SIZE] = {};
    LL sum = 0;
    for(int i = 0; i < N; ++i) {
        cin >> v[i];
        sum += v[i];
        cnt[v[i]]++;
    }

    int q;
    cin >> q;
    while(q--) {
        LL b, c;
        cin >> b >> c;
        sum -= b * cnt[b];
        sum += c * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 4516
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0;i < N;i++)

string to_str(int n){
  ostringstream os;
  os << n;
  return os.str();
}

int main()
{
  int N;
  string s;
  while(cin >> N,N) {
    cin >> s;
    while(N--) {
      string w;
      int np = 0;
      while(np < s.size()){
	char c = s[np];
	int i = 1;
	for(np = np + 1;s[np] == c && np < s.size();np++,i++);
	w += to_str(i);
	w += c;
      }
      s = w;
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

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

    int cnt = 0;
    int lcnt = 0;
    for (int i = 0; i < N; i++) {
        if(S[i] == S[i+1]) {
            cnt += 1;
        }
        if(S[i] != S[i+1]) {
            lcnt += 1;
        }
    }
    for (int i = 0; i < K; i++) {
        if (lcnt / 2 == 0) {
            break;
        }
        else {
            cnt += 2;
        }
    }
    cout << min(cnt, N-1) << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

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

        String ans = "No";
        for(int i=0;i<=X; i++){
            if((2*i+4*(X-i)) == Y){
                ans = "Yes";
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35704
#include<stdio.h>
int main(){
    int x[5], i, k;
    for(i=0;i<5;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<5;i++){
        if(x[i] == 0){
            k = i + 1;
        }
    }
    printf("%d", k);
    return 0;
}


Measured memory_bytes: 1680
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>

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

using namespace std;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

int H, W;

int main() {
    while (true) {
        cin >> H >> W;
        if (H == 0 && W == 0) break;

        for (int j = 0; j < H; j++) {
            for (int i = 0; i < W; i++) {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3092
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include <wchar.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
*/

ll n,h,w;

int main(void){
	cin>>n>>h>>w;
	cout<<(n-h+1)*(n-w+1)<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"errors"
	"fmt"
)

func last_equal(a []string, i string) bool {
	if len(a) == 0 {
		return false
	}
	return a[len(a)-1:][0] == i
}

func count(s string, data []string) (int, error) {
	length := len(s)
	if length == 1 {
		if last_equal(data, s) {
			return 0, errors.New("分割に問題あり")
		}
		// result := append(data, s)
		// if len(result) >= 12 {
		// 	fmt.Println(result)
		// }
		return 1, nil
	}

	// 最小値で初期化
	max_count := 0
	// var tmp_str string
	// var tmp_working_data []string
	i := 0
	for {
		i++
		if i == length {
			break
		}
		first := s[:i]
		second := s[i:]

		// fmt.Println("data:", data)
		// fmt.Println("first:", first)
		// fmt.Println("second:", second)
		// fmt.Println()

		// 分割に問題があればskip
		if last_equal(data, first) {
			// fmt.Println(data)
			// fmt.Println(first)
			continue
		}

		working_data := append(data, first)
		c, err := count(second, working_data)
		if err != nil {
			continue
		}
		max_count = c
		break
	}

	return (max_count + 1), nil
}

func main() {
	var s string
	fmt.Scan(&s)
	data := []string{}
	c, _ := count(s, data)

	fmt.Println(c)
}


Measured memory_bytes: 131968
#include <cstdio>
#include <cmath>
using namespace std;

int main() {
  double v;
  while (~scanf("%lf", &v)) {
    double n = (4.9 * (v / 9.8) * (v / 9.8) + 5) / 5;
    printf("%d\n", (int)ceil(n));
  }
}


Measured memory_bytes: 2564
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

int main(){
    int N, M, A, B, C;
    string s1, s2;
    cin >> s1;
    ll ans = 0;
    rep(i, s1.size()) ans += s1[i] - '0';
    if(ans%9==0)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3752
n = int(input())
a = map(int, input().split())

zero = 0
one = 0
two = 0

def divide_two(arg):
  c = 0
  while True:
    if c >= 2:
      break
    if arg % 2 != 0:
      break
    arg //= 2
    c += 1
  return c 

for i in a:
  counter = divide_two(i)
  if counter == 0:
    zero += 1
  if counter == 1:
    one += 1
  if counter >= 2:
    two += 1
    
if one == 0:
  if zero <= two+1:
    print('Yes')
    exit()
  else:
    print('No')
    exit()
    
else:
  if zero <= two:
    print('Yes')
    exit()
    
  else:
    print('No')
    exit()
    
    
print('No')
  

Measured memory_bytes: 11096
<?php

$input = explode(" ",trim(fgets(STDIN)));
$roop = $input[0];
$min = $input[1];
$max = $input[2];
for($i=1; $i<=$roop;$i++){
     $d = str_split($i);
     $d = array_sum($d);
    if($min <= $d && $d <= $max){
        $total[] = $i;
    }
}
echo array_sum($total);

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

typedef long long ll;

vector<ll> prime;

int main(){
  prime.push_back(2);
  for(ll i=3; i<1000000; i+=2){
    bool flag=true;
    for(ll j=0; j<prime.size()&&i>=prime[j]*prime[j]; j++){
      if(i%prime[j]==0){flag=false; break;}
    }
    if(flag)prime.push_back(i);
  }
  int N, P;
  while(true){
    cin>>N>>P;
    if(N==-1&&P==-1)break;
    vector<ll> prime2;
    int to;
    for(to=0; to<prime.size()&&N>=prime[to]; to++);
    for(int i=to; i<to+P; i++)
      for(int j=i; j<to+P; j++)
        prime2.push_back(prime[i]+prime[j]);
    sort(prime2.begin(), prime2.end());
    cout<<prime2[P-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    double ans=N;
    N=(N+1)/2;
    ans=N/ans;
    cout << fixed << setprecision(10);
    cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;

using Graph = vector<vector<int>>;

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

  int n;
  cin >> n;
  vector<pair<int, int>> edges;
  Graph g(n);
  int max_color = 1;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edges.emplace_back(a, b);
    g[a].push_back(b);
    g[b].push_back(a);
    max_color = max(max_color, int(g[a].size()));
    max_color = max(max_color, int(g[b].size()));
  }

  queue<int> q;
  q.push(0);
  vector<int> used(n, 0);
  map<pair<int, int>, int> ans;
  vector<bool> visit(n);
  while (!q.empty()) {
    int prev = q.front();
    q.pop();
    if (visit[prev])
      continue;
    visit[prev] = true;
    int color = 1;
    for (auto next : g[prev]) {
      if (visit[next])
        continue;
      if (used[prev] == color)
        color++;
      ans[make_pair(prev, next)] = color;
      used[next] = color;
      color++;
      q.push(next);
    }
  }

  cout << max_color << endl;
  for (auto [a, b] : edges)
    cout << ans[make_pair(a, b)] << endl;

  return 0;
}


Measured memory_bytes: 16308
import sys
input = sys.stdin.readline
def main():
  n = int(input())
  l = list(map(int, input().split()))
  l.sort()
  l.append(99999999)
  c = 0
  for i in range(n - 2):
      t = i + 2
      for j in range(i + 1, n - 1):
          for k in range(t, n + 1):
              if l[i] + l[j] <= l[k]:
                  t = k
                  break
          if t > j: c += t - j - 1
          if j + 1 == t: t += 1
  print(c)
if __name__ == "__main__":
  main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int a[127],l=1,i;
char s[27],c;
int main(){
  cin>>s;
  for(i=0;s[i]!='\0';i++)a[s[i]]=1,l++;
  for(c='z';c>='a';c--)if(!a[c])s[l++]=c;
  cout<<(next_permutation(s,s+l)?s:"-1")<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int main()
{
    ll N, A, B, C;
    vector<ll> ABC(3);
    cin >> N >> ABC[0] >> ABC[1] >> ABC[2];

    vector<string> cmds(N);
    rep(i, 0, N) cin >> cmds[i];

    vector<char> res;
    string ref = "ABC";
    rep(i, 0, N)
    {
        int p1, k1;
        p1 = (cmds[i][0] == 'A')? 0: 1;
        k1 = (cmds[i][1] == 'B')? 1: 2;

        int from, to;
        if (ABC[p1] == 0 and ABC[k1] == 0)
        {
            cout << "No" << endl;
            return 0;
        }
        else if (ABC[p1] == 1 and ABC[k1] == 1 and i != N-1)
        {
            int p2 = (cmds[i+1][0] == 'A')? 0: 1;
            int k2 = (cmds[i+1][1] == 'B')? 1: 2;

            if (p1 == p2 or p1 == k2)
            {
                from = k1;
                to = p1;
            }
            else
            {
                from = p1;
                to = k1;
            }
        }
        else
        {
            if (ABC[p1]>ABC[k1])
            {
                from = p1;
                to = k1;
            }
            else
            {
                from = k1;
                to = p1;
            }
        }
        // cout << from << ':' << ABC[from] << ' ' << to << ':' << ABC[to] << endl;
        --ABC[from];
        ++ABC[to];
        res.push_back(ref[to]);
        assert (ABC[from]>=0);
    }

    // output
    cout << "Yes" << endl;
    for (auto r: res)
        printf("%c\n", r);

    return 0;
}

Measured memory_bytes: 6756