akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main(){
  int a, b;
  std::cin >> a >> b;
  if(a < b){ 
      std::cout << "a < b";
  }
  else if(a > b){ 
      std::cout << "a > b";
  }
  else{ 
      std::cout << "a == b";
  }
  std::cout << std::endl;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int n;
	cin>>n;
	int a[n];
	int s=0;
	int k;
	cin>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>=k)s++;
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<iomanip>
using namespace std;
int main(void){
    int a,b,d,r;
    double f;
    cin>>a>>b>>d>>r;
    d=a/b;
    r=a%b;
    f=(double)(a)/(double)(b);
    cout<<d<<" "<<r<<" ";
    cout<< fixed << setprecision(5)<< f ;
    cout<<endl;
    
    
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD (int)(1e9+7)
#define ceil(x, y) (x%y==0? (x/y) : (x/y+1))
#define FOR(i, N) for(int i = 0; i < N; ++i)
#define FOR1(i, N) for(int i = 1; i <= N; ++i)
#define vi vector <int>
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mset(a, v) memset(a, v, sizeof(a))
#define all(v) (v).begin(), (v).end()
#define INF 2e9
#define EPS 1e-9
#define int long long
int fun(int wts[], int vals[], int n, int w){
    int dp[w+1];
    mset(dp, 0);
    /*dp[i] = maximum total value of items with total weight exactly i*/
    for(int i = 1; i <= n; i++){
        /*all knapsack with capacity >= wt[i] will be able to accomodate object i*/
        for(int j = w; j >= wts[i]; j--){
            dp[j] = max(dp[j], vals[i] + dp[j-wts[i]]);
        }
    }
    return dp[w];
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
	int T=1;
	//cin >> T;
	FOR1(i, T)
	{
		//cout << "Case #" << i << ": ";
       int n, w;
       cin >> n >> w;
       int vals[n+1], wts[n+1];
       FOR1(i, n){
           cin >> wts[i] >> vals[i];
       }
       cout << fun(wts, vals, n, w);
		cout<<'\n';
	}
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
main(){
long long int n;
cin>>n;
double p[n];
for(int i=0;i<n;i++){cin>>p[i];}
double ans[n+1];
ans[0]=1;
//memset(ans,0,sizeof(ans));
for(int i=1;i<=n;i++)for(int j=i;j>=0;j--){
	if(j==0)ans[j]=ans[j]*(1-p[i-1]);
	else{


		if(j==i)ans[j]=ans[j-1]*p[i-1];
		else{
ans[j]=ans[j-1]*p[i-1]+ans[j]*(1-p[i-1]);
}}
//cout<<ans[j];
//cout<<" "<<j<<endl;




}
double   sum=0;
for(int i=0;i<=n;i++)
{
if(i>(n-i))sum+=ans[i];
}

printf("%.10f",sum);

}


Measured memory_bytes: 3836
#include <iostream>
#include <vector>
#include <cstdio>
 
template<class T>
using Graph = std::vector<std::vector<T>>;
 
bool dfs(Graph<int> &G, int step, int u, int v,
         std::vector<bool> &visited)
{
    int n = G.size();
    int x = (step < n / 2 ? u : v);
    if (step == n - 1) {
        return true;
    }
     
    bool ret = false;
    for (int next : G[x]) {
        if (!visited[next]) {
            visited[next] = true;
 
            if (step < n / 2) {
                ret |= dfs(G, step + 1, next, v, visited);
            } else {
                ret |= dfs(G, step + 1, u, next, visited);
            }           
        }        
    }
 
    return ret;
}
 
bool solve(Graph<int> &G, int u, int v)
{
    int n = G.size();
    if (n & 1) {
        return false;
    }
 
    std::vector<bool> visited(n, false);
    visited[u] = visited[v] = true;
    return dfs(G, 1, u, v, visited);
}
 
int main()
{
    int n, u, v;
    scanf("%d %d %d", &n, &u, &v);
    u--; v--;
     
    Graph<int> G(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        scanf("%d %d", &a, &b);
        a--; b--;
 
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
 
    printf("%s\n", (solve(G, u, v) ? "Yes" : "No"));
     
    return 0;
}

Measured memory_bytes: 17640
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<lint> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    int n, c, k;
    cin >> n >> c >> k;
    vi v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    sort(all(v));
    int cc = 0;
    for (int i = 0; i < n;)
    {
        int a = v[i];
        int temp = c;
        while (i < n && temp-- && ((a + k) >= v[i]))
        {
            i++;
        }
        cc++;
    }
    cout << cc << endl;
    return 0;
}

Measured memory_bytes: 1024
n,m = map(int, input().split())
ans = 0

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    #divisors.sort()
    return divisors

divisors = make_divisors(m)

for d in divisors:
    if m >= n*d and ans < d:
        ans = d
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[] a = new int[N+1];
    
    Arrays.fill(a, 0);

    for (int i = 0; i < M; i++) {
      int m = sc.nextInt();
      a[m] = 1;
    }

    sc.close();

    long[] dp = new long[N+1];
    
    long mod = 1000000007;

    dp[N] = 1;

    for (int i = N-1; 0 <= i ; i--) {
      if (a[i] == 1){
        dp[i] = 0;
      } else {
        if (i == N - 1){
          dp[i] = dp[N];
        } else if (N < i+2){
          dp[i] = (dp[i+1] + dp[N]) % mod;
        }else {
          dp[i] = (dp[i+1] + dp[i+2]) % mod;
        }
      }
    }

    System.out.println(dp[0]);
    
  }

}

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

using namespace std;

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

    vector<int> A;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        A.push_back(a);
    }

    vector<int> Ranking(n,0);
    for(int i=0;i<n;i++){
        Ranking[A[i]-1] = i+1;
    }

    for(int i=0;i<n;i++){
        cout << Ranking[i] << " ";
    }

    return 0;
}

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

ll a[51];
ll p[51];

 ll solve(ll n, ll x){
   ll ans = 0;
   if(n == 0){
     ans += 1;
   }
   else if(x == 1){
     ans += 0;
   }
   else if(x <= 1 + a[n-1]){
     ans += solve(n - 1, x - 1);
   }
   else if(x == 2 + a[n-1]){
     ans += p[n-1] + 1;
   }
   else if(x <= 2 + 2 * a[n-1]){
     ans += p[n-1] + 1 + solve(n - 1, x - 2 - a[n-1]);
   }
   else{
     ans += 2 * p[n-1] + 1;
   }
   return ans;
 }

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll n, x;
  cin >> n >> x;

  a[0] = 1;
  p[0] = 1;
  rep(i, 51){
    a[i+1] = a[i] * 2 + 3;
    p[i+1] = p[i] * 2 + 1;
  }

  ll ans = solve(n, x);

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,x,y,z1,z2,n;

  scanf("%d%d",&x,&y);
  if(x>y){z1=y;z2=x;}
  else {z1=x;z2=y;}
  while(z2%z1!=0){
    n=z1;
  z1=z2%z1;
  z2=n;
}

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

return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>                                           
 
#define int long long
//#pragma GCC optimize("Ofast")
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define all(x) x.begin(), x.end()
#define sz(s) (int)s.size()
#define pb push_back
#define ppb pop_back
#define s second
#define f first
 
 
using namespace std;
 
 
typedef pair < long long, long long > pll;    
typedef pair < int, int > pii;
typedef unsigned long long ull;         
typedef vector < pii > vpii;
typedef vector < int > vi;
typedef long double ldb;  
typedef long long ll;  
typedef double db;                             
 
 
const int inf = 1e9, maxn = 4e5 + 148, mod = 1e9 + 7, N = 2e2 + 11;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1}, block = 555;
const pii base = {1171, 3307}, Mod = {1e9 + 7, 1e9 + 9};
const db eps = 1e-12, pi = 3.14159265359;
const ll INF = 1e18;


vi g[N];
string s;
int n, col[N], d[N][N];


void dfs (int v, int c = 1) {
	col[v] = c;	
	for (auto to : g[v])
		if (!col[to])
			dfs(to, 3 - c);
		else if (col[to] == col[v]) {
			cout << -1;
			exit(0);
		}
}


main () {
	cin >> n;
	forn (i, 1, n) {
		cin >> s;
		forn (j, 1, n)
			if (s[j - 1] == '1')
				g[i].pb(j);
	}

	dfs(1);
	forn (i, 1, n)
		forn (j, 1, n)				 
			d[i][j] = inf;

	forn (i, 1, n) {
		d[i][i] = 0;
		for (auto j : g[i])
			d[i][j] = 1;
	}

	forn (k, 1, n)
		forn (i, 1, n)
			forn (j, 1, n)
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

	int mx = 0;

	forn (i, 1, n)
		forn (j, 1, n)
			mx = max(mx, d[i][j]);
	cout << mx + 1 << endl;	
}
                        

Measured memory_bytes: 768
N = int(input())
H = list(map(int, input().split()))
for i in range(N - 2, -1, -1):
    if H[i] <= H[i+1]:
        continue
    elif H[i] - 1 == H[i+1]:
        H[i] -= 1
    else:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 20832
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> v;
ll n,s[6],t[7];
void f(ll a,ll b){
    //cout<<a<<b<<endl;
    if(a==0){
        v.push_back(b);
        return ;
    }
    for(int i=5;i>=0;i--){
        if(a>=s[i]){
            if(s[i]==1){
                f(0,b+a);
                break;
            }
            f(a-s[i],b+1);
            break;
        }
    }
    
    for(int i=6;i>=0;i--){
        if(a>=t[i]){
            if(t[i]==1){
                f(0,b+a);
                break;
            }
            f(a-t[i],b+1);
            break;
        }
    }
    return ;
}
int main(void){
    cin>>n;
    s[0]=1;
    t[0]=1;
    for(int i=0;i<5;i++){
        s[i+1]=s[i]*9;
    }
    for(int i=0;i<6;i++){
        t[i+1]=t[i]*6;
    }
    //cout<<t[6]<<endl;
    f(n,0);
    sort(v.begin(),v.end());
    cout<<v[0]<<endl;
}


Measured memory_bytes: 33636
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
#define endl '\n'
const int MAX = 8;
using namespace std;
int n;
bool table[MAX + 1][MAX + 1]; // table:無向グラフ

int dfs(int cur, bool visited[])
{
    bool all_visited = true; // すべての点を通ったかどうか
    rep(i, n)
    {
        // どこか一つでも通ったことがないならall_visitedはfalse
        if (!visited[i]) {
            all_visited = false;
        }
    }
    // すべての点に通ったならそこで終了
    if (all_visited) {
        return 1;
    }

    int cnt = 0; // cnt:すべての点を通る通り方
    rep(next, n)
    {
        if (table[cur][next] && !visited[next]) { // 今の位置curから次の位置nextに行ける ∧ nextに通ったことがない
            visited[next] = true;  // nextに行ったことにする
            cnt += dfs(next, visited); // nextに行ってすべて通ったことがあるならcnt++, ないならnextから次の点へ行く
            visited[next] = false; // curから別のnextに行けように，nextに行ったことがないとする
        }
    }
    return cnt;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m;
    cin >> n >> m;
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        table[a - 1][b - 1] = table[b - 1][a - 1] = true;
    }
    bool visited[MAX]; // visited:各点を通ったかどうか
    visited[0] = true;
    for (int i = 1; i < n; i++) {
        visited[i] = false;
    }
    cout << dfs(0, visited) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int ans = 0;
    int current = 0;
    for(char c : sc.next().toCharArray()) {
      if (c == 'R') {
        current++;
        ans = Math.max(ans, current);
      } else {
        current = 0;
      }
    }
    pw.println(ans);
  }
}


Measured memory_bytes: 35680
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll n,a,b;
    cin >> n >> a >> b;
    if(!((b-a)&1)){
        pr((b-a)/2);
    }else{
        if(a-1 < n-b){
            pr(a+(b-a-1)/2);
        }else{
            // pr(n-b+(n-a+(n-b))/2);
            pr(n-b+1+(b-a-1)/2);
        }
        // pr(min(max(a-1, b-1), max(n-a, n-b)));
    }
}

Measured memory_bytes: 256
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"
exit $?
'''
import sys
import math

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]

h, a = _ia()
print(math.ceil(h/float(a)))


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

int main() {
  int a, b, hantei;
  cin >> a >> b;

  hantei = a * b % 2;

  if (hantei == 0) {
    cout << "Even" << endl;
  }
  else{
    cout <<"Odd"<<endl;
  }  
}

Measured memory_bytes: 3596
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var N = Sarray()[0];
            var Ai = Sarray();
            var max = Ai.Max();
            var maxIdx = Ai.Select((a, i) => (a, i)).First(ai => ai.a == max).i;
            var min = Ai.Min();
            var minIdx = Ai.Select((a, i) => (a, i)).First(ai => ai.a == min).i;
            WriteLine(2 * N - 1);
            if (0 <= min + max)
            {
                for (var i = 0; i < N; ++i)
                    WriteLine($"{maxIdx + 1} {i + 1}");
                for (var i = 1; i < N; ++i)
                    WriteLine($"{i} {i + 1}");
            }
            else
            {
                for (var i = 0; i < N; ++i)
                    WriteLine($"{minIdx + 1} {i + 1}");
                for (var i = N - 1; 0 < i; --i)
                    WriteLine($"{i + 1} {i}");
            }
        }

        static long Mod = (long)1e9 + 7;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28372
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, q;
    cin >> n >> k >> q;

    int a[100010] = {};

    for (int i = 0; i < q; i++)
    {
        int tmp;
        cin >> tmp;
        a[tmp-1]++;
    }

    for (int i = 0; i < n; i++)
    {
        if (k - (q - a[i]) > 0) {
            cout << "Yes" << "\n";
        } else {
            cout << "No" << "\n";
        }
    }
    


    

    
}

Measured memory_bytes: 1024
import sys
from collections import defaultdict
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
L = [[int(v) for v in input().split()] for _ in range(N - 1)]
Q, K = map(int, input().split())
QL = [[int(v) - 1 for v in input().split()] for _ in range(Q)]

m = [set() for _ in range(N)]
c = {}
for x, y, z in L:
    m[x - 1].add(y - 1)
    m[y - 1].add(x - 1)

    if c.get(x - 1) == None:
        c[x - 1] = {}

    if c.get(y - 1) == None:
        c[y - 1] = {}

    c[x - 1][y - 1] = z
    c[y - 1][x - 1] = z

s = [None] * N
s[K - 1] = 0

def f(index, b):
    for v in m[index]:
        if s[v] == None:
            s[v] = b + c[index][v]
            f(v, s[v])
        else:
            if s[v] > b + c[index][v]:
                s[v] = b + c[index][v]
                f(v, s[v])

f(K - 1, 0)

for x, y in QL:
    print(s[x] + s[y])

Measured memory_bytes: 213784
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    long int sum;
    long int ans=0;
    int num;
    for(int i=1; i<=n; i++){
        sum=0;
        num=i;
        for(int j=0; j<5; j++){
            sum+=num%10;
            num/=10;
        }
        if(a<=sum && sum<=b){
            ans+=i;
            //cout << i << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
#include <stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    int i,q;
    for(i=1;i<10;i++){
        if(n%i==0){
            if(n/i<10){
                printf("Yes\n" );
                return 0;
            }
        }
    }printf("No\n" );
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int A[N][N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        if (A[i][j] > A[i][k]+A[k][j]) {
          cout << -1;
          return 0;
        }
      }
    }
  }
  long long distance = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      bool direct = true;
      for (int k = 0; k < N; k++) {
        if (i != k && j != k && A[i][j] == A[i][k]+A[k][j]) {
          direct = false;
          break;
        }
      }
      if (direct) {
        distance += A[i][j];
      }
    }
  }
  distance /= 2;
  cout << distance;
}

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

using namespace std;
using ll = long long;

int main() {

	int a,b;
	cin >> a >> b;

	int ans = a;

	if(b < a) { ans--; }
	cout << ans;
	return 0;
}



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

#define REP(i, a, b) for ( int i = (a); i < (b); i++ )
#define REVREP(i, a, b) for ( int i = (a); i >= (b); i--)
#define DEBUG_INT(var) printf("the value of "#var" is %d\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define YES puts("YES")
#define NO  puts("NO")
#define Yes puts("Yes")
#define No  puts("No")

using namespace std;

typedef long long ll;

//2 2 3 5 5
//1 0 0 1 0 

// 1  1  1  1  2  3  4
// 0 -1 -2 -3 -3 -3 -3
// sum: -15
// ave: -2 

ll ans, N;
ll A[200005];

int main(void) {
    scanf("%lld", &N);
    REP(i, 0, N) {
    	ll a;
    	scanf("%lld", &a);
    	A[i] = a - (i + 1); 
    }

    sort(A, A+N);

    int med = A[N / 2];

    REP(i, 0, N) ans += abs(A[i] - med);
    
    printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<stdlib.h>

int main(void){
  int a,b,k,i;
  
  scanf("%d",&k);
  scanf("%d",&a);
  scanf("%d",&b);
  
  for(i=a;i<=b;i++){
    if(i%k==0){
      printf("OK");
     return 0;
    }
  }
  printf("NG");
  
  return 0;
}
    

Measured memory_bytes: 1732
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System;
using System.Numerics;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split().Select(int.Parse).ToArray();
	public const int MOD = 1000000007;
	public K()
	{
		WriteLine(S());
	}
	long S()
	{
		var N = F();
		var A = G();
		var d = new Dictionary<int, int>();
		foreach (var a in A) if (!d.ContainsKey(-a)) d[-a] = 1; else d[-a]++;
		var e = new SortedDictionary<int, int>();
		foreach (var x in d) if (x.Value >= 4) e[x.Key] = 2; else if (x.Value >= 2) e[x.Key] = 1;
		if (e.Count == 0) return 0;
		var m = e.Keys.First();
		if (e.Count == 1 && e[m] < 2) return 0;
		if (e[m] >= 2) return (long)m * m;
		e.Remove(m);
		return (long)m * e.Keys.First();
	}
}


Measured memory_bytes: 32604
package main

import "fmt"

func main() {
	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)
	fmt.Println(Min(A, B) + Min(C, D))
}

func Min(a, b int) int {
	if b < a {
		return b
	}
	return a
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 
int chmax(int &a, int b) {return a = max(a, b);}

int solve(int n){
	vector<int> block(n);
	for(int i=0; i<n; i++) cin >> block[i];

	//dp[l][r]: 区間[l, r]考えた時，取り除けるブロックの最大個数
	//http://kutimoti.hatenablog.com/entry/2018/03/10/220819
	vector<vector<int>> dp(n+1, vector<int>(n+1, 0));
	//初期化は0でよい


	for(int w=2; w<=n; w++){
		for(int l=0; l+w<=n; l++){
			int r = l+w;
			if(dp[l+1][r-1]==w-2 && abs(block[l]-block[r-1])<=1) dp[l][r] = w;
			for(int mid=l; mid<r; mid++){
				chmax(dp[l][r], dp[l][mid]+dp[mid][r]);
			}
		}
	}
	// cout << " block: "; print_vec(block);
	// print_vec2(dp);
	return dp[0][n];
}

int main(){
	
	vector<int> ans;
	while(true){
		int n;
		cin >> n;
		if(n == 0) break;
		ans.push_back(solve(n));
	}
	for(int i=0; i<ans.size(); i++) cout << ans[i] << endl;


	return 0;
}



Measured memory_bytes: 3176
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  ll H, W, N; cin >> H >> W >> N;
  map<ll, map<ll,ll>> black;

  rep(i, N) {
    ll a, b; cin >> a >> b;
    black[a-1][b-1]++; black[a-1][b]++; black[a-1][b+1]++;
    black[a][b-1]++; black[a][b]++; black[a][b+1]++;
    black[a+1][b-1]++; black[a+1][b]++; black[a+1][b+1]++;
  }

  ll result[10] = {};
  for (auto h: black) {
    for (auto w: h.second) {
      if (h.first>=2 && h.first<=H-1 && w.first>=2 && w.first<=W-1) {
        result[w.second]++;
      }
    }
  }

  result[0] = (H-2)*(W-2); rep(i,9) result[0] -= result[i+1];
  for (auto x:result) cout << x << endl;
  return 0;
}

Measured memory_bytes: 84608
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, p;
    cin >> n >> p;
    vector<int> a(n);
    rep(i, 0, n){
        cin >> a[i];
        a[i] %= 2;
    }
    int dp[2] = {0};
    dp[0] = 1;
    rep(i, 0, n){
        if(a[i] == 0){
            dp[0] += dp[0];
            dp[1] += dp[1];
        }else{
            int tmp = dp[0] + dp[1];
            dp[1] += dp[0];
            dp[0] = tmp;
        }
        // cout << dp[0] << " " << dp[1] << endl;
    }
    cout << dp[p] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int read()
{
    char c=getchar();int f=1,sum=0;
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
    return sum*f;
}
int n,m;
char a[505][505],b[505][505],c[505][505];
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++) scanf("%s",a[i]+1);
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++)
	{
		b[i][j]=c[i][j]='.';
		if(a[i][j]=='#') b[i][j]=c[i][j]='#';
	}
	for(int i=1;i<=m;i++) b[1][i]=c[n][i]='#';
	for(int j=1;j<=m;j++) for(int i=2;i<n;i++)  if(j&1) b[i][j]='#';else c[i][j]='#';
	for(int i=1;i<=n;i++) printf("%s\n",b[i]+1);
	puts("");
	for(int i=1;i<=n;i++) printf("%s\n",c[i]+1);
	return 0;
}


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

int main() {
  vector<int> A(3);
  cin >> A.at(0) >> A.at(1) >> A.at(2);
  int f=0;
  int s=0;
    for(int i=0;i<3;i++){
      if(A.at(i) == 5){
        f +=1;
      }
      else if(A.at(i) == 7){
        s += 1;
      }
    }
  
    if(f == 2 && s == 1){
      cout << "YES" << endl;
    }
    else{
      cout << "NO" << endl;
    }
  
  return 0;
}


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

int main () {
  int N, K; // 1 <= N, K <= 10 
  cin >> N >> K;
  int m = 1;
  int i = 0;
  while ((i < N)&&(m < K)) {
    m *= 2;
    i++;
  }
  for (int j = 0; j < N - i; j++) {
    m += K;
  }
  cout << m << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<bitset>

using namespace std;

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

    std::vector<std::vector<int>> v;
    for(int i=0; i<M; ++i) {
        int nn;
        cin >> nn;
        std::vector<int> tmp;
        for(int j=0; j<nn; ++j) {
            int t;
            cin >> t;
            tmp.push_back(t);
        }
        v.push_back(tmp);
    }
    vector<int> p;
    for(int i=0; i<M; ++i) {
        int pp;
        cin >> pp;
        p.push_back(pp);
    }

    int max = pow(2, N);

    int result = 0;
    for(int i=0; i<max; ++i) {
        auto bs = bitset<10>(i);
        bool okay = true;
        for(int j=0; j < v.size(); ++j) {
            int n = 0;
            for(auto vvv: v[j]) {
                n += bs[vvv-1];
            }
            if((n % 2) != p[j]) {
                okay = false;
                break;
            }
        }
        if(okay) {
            result++;
        }
    }
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 512
import 'dart:async';
import 'dart:io';
import 'dart:convert';

Stream<String> get lineStream =>
    stdin.transform(utf8.decoder).transform(const LineSplitter());

Future<List<String>> readLines() async {
  final lines = <String>[];
  await for (var line in lineStream) {
    lines.add(line);
  }
  return lines;
}

void main() async {
  final lines = await readLines();
  final n = int.parse(lines[0]);
  final c = lines[1];
  final charR = 'R'.codeUnitAt(0);
  var red = 0;
  var runes = List.from(c.runes);
  for (var i = 0; i < n; i++) {
    if (runes[i] == charR) {
      red++;
    }
  }
  var count = 0;
  for (var i = 0; i < red; i++) {
    if (runes[i] != charR) {
      count++;
    }
  }
  print('$count');
}

Measured memory_bytes: 17556
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String t = sc.next();
		if (t.equals("?")) {
			System.out.println("D");
			return;
		}

		System.out.println(t.replace('?', 'D'));
	}

}



Measured memory_bytes: 41112
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;

  vector<int> n{a, b, c};
  sort(n.begin(), n.end());
  
  cout << n[2] * 10 + n[1] + n[0] << endl;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int a, b;
    cin >> a >> b;
    dump(6 - a - b);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

signed main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int a, b;
	cin >> a >> b;
	cout << (a-1)*(b-1) << endl;
	rtn 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define isin(i,a,b) ((a) <= (i) && (i) <= (b))
#define uni(a) (a).erase(unique(all(a)),(a).end())
#define fi first
#define se second
#define pb push_back
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll  = long long;          using vi  = vector<int>;
using unit= unsigned;           using vl  = vector<ll>;
using ull = unsigned long long; using vvi = vector<vi>;
using P   = pair<int,int>;      using vvl = vector<vl>;
                                using vp  = vector<P>;
void _main(); int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T>string join(const v(T)&v){ stringstream s; rep(i,0,sz(v))s<<' '<<v[i]; return s.str().substr(1); }
template<class T>istream &operator>>(istream&i, v(T)&v){ fore(x,v){ i >> v; } return i; }
template<class T>ostream &operator<<(ostream&o, const v(T)&v){ o<<"["; fore(x,v)o<<x<<","; o<<"]"; return o; }
template<class T>ostream &operator<<(ostream&o, const deque<T>&v){ o<<"deq["; fore(x,v)o<<x<<","; o<<"]"; return o; }
template<class T>ostream &operator<<(ostream&o, const set<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T>ostream &operator<<(ostream&o, const unordered_set<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T>ostream &operator<<(ostream&o, const multiset<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T>ostream &operator<<(ostream&o, const unordered_multiset<T>&v){ o<<"{"; fore(x,v)o<<x<<","; o<<"}"; return o; }
template<class T1,class T2>ostream &operator<<(ostream &o, const pair<T1,T2>&p){ o<<"("<<p.fi<<","<<p.se<<")"; return o; }
template<class TK,class TV>ostream &operator<<(ostream &o, const map<TK,TV>&m){ o<<"{"; fore(x,m)o<<x.fi<<"=>"<<x.se<<","; o<<"}"; return o; }
template<class TK,class TV>ostream &operator<<(ostream &o, const unordered_map<TK,TV>&m){ o<<"{"; fore(x,m)o<<x.fi<<"=>"<<x.se<<","; o<<"}"; return o; }
template<class T>void YES(T c){ if(c) cout<<"YES"<<endl; else cout<<"NO"<<endl; }
template<class T>void Yes(T c){ if(c) cout<<"Yes"<< endl; else cout<<"No"<<endl; }
template<class T>void POSS(T c){ if(c) cout<<"POSSIBLE"<<endl; else cout<<"IMPOSSIBLE"<<endl; }
template<class T>void Poss(T c){ if(c) cout<<"Possible"<<endl; else cout<<"Impossible"<<endl; }
template<class T>void chmax(T &a, const T &b){ if(a<b) a=b; }
template<class T>void chmin(T &a, const T &b){ if(b<a) a=b; }
template<class T>T gcd(T a, T b){ return (b==0) ? a : gcd(b,a%b); }
template<class T>T lcm(T a, T b){ return a * (b / gcd(a,b)); }
const double  EPS = 1e-10;
const double  PI  = acos(-1.0);
const int     INF = INT_MAX / 2;
const ll      INFL= 1LL << 60;
const int dx[] = { -1, 0, 1, 0 , -1,-1, 1, 1 };
const int dy[] = {  0, 1, 0,-1 , -1, 1,-1, 1 };

void _main() {
  int a;
  string s;
  cin >> a >> s;

  if (a >= 3200) cout << s << endl;
  else puts("red");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
 
 
 
 
int main() {
    int k,s;
    cin>>k>>s;
    int count=0;
    int x,y,z;
    rep(x,k+1){
        rep(y,k+1){
            z=s-x-y;
            if(z<0||z>k)continue;
            count++;
        }
    }
    cout<<count<<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const long long INF=1145141919,MOD=1e9+7;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

int main(){
    int n;
    cin>>n;
    while(n!=0){
        priority_queue<int,vector<int>,greater<int>> sum;
        int count=0,ans=0;
        for(int i=0;i<n;i++){
            sum.push(i);
            ans+=i;
            while(ans>n){
                ans-=sum.top();
                sum.pop();
            }
            if(ans==n){
                count++;
            }
        }
        cout<<count<<endl;
        cin>>n;
    }
    return 0;
}



Measured memory_bytes: 3072
#include<stdio.h>

int main(void){
    int n,i,j,k;

    scanf("%d",&n);

    int mm[n];
    int count[n];

    for(i=0;i<=n;i++){
        mm[i]=0;
        count[i]=0;
    }

    for(i=1;i<n;i++){
        scanf("%d",&mm[i]);    
    }

    for(j=1;j<n;j++){
        count[mm[j]] ++;
    }

    for(k=1;k<=n;k++){
        printf("%d\n",count[k]);
    }

}

Measured memory_bytes: 3292
<?php
fscanf(STDIN, "%s", $S);
$S = str_split($S);
fscanf(STDIN, "%s", $T);
$T = str_split($T);

$min_count;
for ($i = 0; $i < count($S)-count($T)+1; $i++) {
    $count = 0;
    for ($j = 0; $j < count($T); $j++) {
        if ($S[$i+$j] !== $T[$j]) {
            $count++;
        }
    }

    if ($count < $min_count || $i == 0) {
        $min_count = $count;
    }
}

echo $min_count . "\n";

Measured memory_bytes: 16064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define pf push_front
#define mt make_tuple
#define popb pop_back
#define popf pop_front
#define int long long int
#define vi         vector<int>
#define vll        vector<ll>
#define vpii       vector<pair<int,int>>
#define vpll       vector<pair<ll,ll>>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(container) int((container).size())
#define rep(i,a,b) for(i=a;i<b;i++)
#define tr(container,it)   for(auto it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())      //set,map etc.
#define cpresent(container, element) (find(all(container),element) != container.end())    //vector
#define hell 1000000007
#define PI 3.14159265
#define mod 998244353
#define fs first
#define sc second
#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
void solve()
{
  int n,i,j;
  cin>>n;
  long double p[n+1];
  rep(i,1,n+1)cin>>p[i];
  long double dp[n+1][n+1];
  for(i=0;i<=n;i++)
    for(j=0;j<=n;j++)dp[i][j]=0;
  dp[0][0]=1;
  for(i=1;i<=n;i++)
  {
    dp[i][0]=(1-p[i])*dp[i-1][0];
    for(j=1;j<=i;j++)
    {
      dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
    }
  }
  double ans=0;
  for(j=n/2+1;j<=n;j++)
    ans+=dp[n][j];
  cout<<setprecision(9)<<ans;
}
signed main()
{
  fastio
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  int t;
  t=1;
  //cin>>t;
  while(t--)
  solve();
  TIME
  return 0;
}

Measured memory_bytes: 140928
#include <iostream>

int main(void) {
  int N;  //ドーナツの種類
  int X;  //持っている粉の量
  std::cin >> N;
  std::cin >> X;

  int m[N]; //ドーナツ[i]に必要な粉の量
  int i;
  int sum = 0;
  int min = 1000000;
  for(i=0; i<N; i++) {
    std::cin >> m[i];
    sum += m[i];
    if(m[i]<min) {
      min = m[i];
    }
  }
  
  std::cout << N + ( X - sum ) / min << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <functional>
using namespace std;
bool cycle_detection(vector<vector<int> > &G) {
	vector<bool> vis(G.size());
	function<bool(int, int, bool)> rec = [&](int pos, int start, bool flag) {
		if (pos == start && flag) return true;
		if (flag) vis[pos] = true;
		bool ret = false;
		for (int e : G[pos]) {
			if (!vis[e]) ret = ret || rec(e, start, true);
		}
		return ret;
	};
	for (int i = 0; i < G.size(); i++) {
		fill(vis.begin(), vis.end(), false);
		if (rec(i, i, false)) return true;
	}
	return false;
}
int V, E, a, b;
int main() {
	cin >> V >> E;
	vector<vector<int> > G(V);
	for (int i = 0; i < E; i++) {
		cin >> a >> b;
		G[a].push_back(b);
	}
	cout << cycle_detection(G) << endl;
	return 0;
}

Measured memory_bytes: 3160
#include <stdio.h>

int main()
{
    int n;
    long long a[100001];
    long long max = 1000000000000000000;
    long long mul = 1;

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
        if (a[i] == 0)
        {
            printf("0");
            return 0;
        }
    }

    for (int i = 0; i < n; i++)
    {
        if (a[i] > max)
        {
            printf("-1");
            return 0;
        }
        mul *= a[i];
        max /= a[i];
    }
    printf("%lld", mul);
    return 0;
}

Measured memory_bytes: 2488
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/priank/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,p,s,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    vi a;
    string t;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

lli solve(const string t)
{
    lli rr=0,ss=0,pp=0;
    for(auto x:t)
    {
        lli curp,curs,curr;
        if(x=='r')
        {
            curp=max(ss,rr)+p;
            curs=max(pp,rr);
            curr=max(pp,ss);
        }

        if(x=='p')
        {
            curp=max(ss,rr);
            curs=max(pp,rr)+s;
            curr=max(pp,ss);
        }

        if(x=='s')
        {
            curp=max(ss,rr);
            curs=max(pp,rr);
            curr=max(pp,ss)+r;
        }

        pp=curp;
        rr=curr;
        ss=curs;
    }
    dbg(t,pp,ss,rr);
    return max({pp,ss,rr});
}

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n>>k;
    cin>>r>>s>>p;
    cin>>t;
    lli ans=0;
    for(lli i=0;i<k;++i)
    {
        string s="";
        for(lli j=i;j<n;j+=k)
            s+=t[j];
        ans+=solve(s);
    }
    cout<<ans<<endl;
}   aryanc403();
    return 0;
}


Measured memory_bytes: 640
def main():
    N,K = map(int, input().split())
    pi = list(map(int, input().split()))
    max_num = 0
    new_pi = [0] * N
    sum_new_pi = [0] * (N+1)

    for i in range(N):
        new_pi[i] += (1+pi[i])/2

    for i in range(N):
        sum_new_pi[i+1] = sum_new_pi[i] + new_pi[i]

    for i in range(N):
        if i+K > N:
            break
        s = sum_new_pi[i+K] - sum_new_pi[i]
        if s > max_num:
            max_num = s

    print(max_num)

if __name__ == "__main__":
    main()


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

int main() {
    int N, M, ans = 0;
    cin >> N >> M;
    vector<vector<bool>> reachable(N, vector<bool>(N));
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        reachable[a][b] = reachable[b][a] = true;
    }
    vector<int> route(N);
    for(int i = 0; i < N; ++i)
        route[i] = i;
    do {
        int ok = true;
        for(int i = 1; i < N; ++i) {
            if(!reachable[route[i - 1]][route[i]]) {
                ok = false;
                break;
            }
        }
        if(ok)
            ++ans;
    } while(next_permutation(route.begin() + 1, route.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; ll D; cin >> N >> D;
    int ans=0;
    for (;N--;){
        ll X,Y; cin >> X >> Y;
        ans+=(X*X+Y*Y<=D*D);
    }
    cout << ans << '\n';
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	vector<int> res(n+1);
	for (int i = 2; i <= n; ++i){
		int x;
		cin>>x;
		++res[x];
	}
	for (int i = 1; i <= n; ++i){
		cout<<res[i]<<"\n";
	}
}


Measured memory_bytes: 3992
#include<iostream>
#include<math.h>
 
using namespace std;
 
int main()
{
  long long  a,b,c;
  cin >> a >> b >> c;
  
  if (a+b+2*sqrtl(a*b) < c)
  {
      cout << "Yes" <<endl;
  }
  else
  {
          cout << "No" <<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import collections
import sys
N = int(input())
S = [input() for _ in range(N)]

c = collections.Counter(S)
ans = []
li=c.most_common()
for i in range(len(li)):
    if i == 0:
        ans.append(((li[0][0])))
    
    if i != 0:
        if (li[i-1][1]) == (li[i][1]):
            
            ans.append(((li[i][0])))
        else:
            break

ans.sort()

for i in ans:
    print(i)


Measured memory_bytes: 47636