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

using namespace std;

typedef long long ll;

const int N=10;
int n,m,k;
bool visited[N][N],visrow[N],viscol[N];
char arr[N][N];


bool counter(){
    int sum=0;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            if (arr[i][j]=='#' && !visrow[i] && !viscol[j]){
                sum++;
            }
        }
    }
    return sum==k;
}

int solve1(int ind){
    if (ind==n)
        return counter();
    int ret=0;
    visrow[ind]=true;
    ret+=solve1(ind+1);
    visrow[ind]=false;
    ret+=solve1(ind+1);
    return ret;
}

int solve(int ind){
    if (ind==m)
        return solve1(0);
    int ret=0;
    viscol[ind]=true;
    ret+=solve(ind+1);
    viscol[ind]=false;
    ret+=solve(ind+1);
    return ret;
}

int main()
{
    cin>>n>>m>>k;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++)
            cin>>arr[i][j];
    }
    cout<<solve(0);

    return 0;
}


Measured memory_bytes: 3576
//by zjq
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
const int maxm = 2e5+10;
typedef long long LL;
LL A[maxn]; int n, edgecnt, head[maxn];
struct edge{int v, nxt;} E[maxm];
inline int read()
{
    int x = 0 , f = 1; char ch = getchar();
    while(ch<'0'||ch>'9') {if(ch=='-')f*=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch-48);ch=getchar();}
    return x * f;
}
inline void addedge(int u, int v)
{
    E[++edgecnt].v = v, E[edgecnt].nxt = head[u], head[u] = edgecnt;
    E[++edgecnt].v = u, E[edgecnt].nxt = head[v], head[v] = edgecnt;
}
LL dfs(int u, int fa)
{
    int cnt = 0;
    for(int i = head[u]; ~i; i = E[i].nxt)
        if(u != E[i].v && fa != E[i].v) cnt++;
    if(!cnt)
        return A[u];
    LL tot = 0, x1 = 0, x2 = 0, maxw = 0, sumw;
    for(int i = head[u]; ~i; i = E[i].nxt){
        int v = E[i].v;
        if(v == fa) continue;
        sumw = dfs(v, u);
        maxw = max(maxw, sumw);
        tot += sumw;
    }
    x2 = tot - A[u];
    x1 = A[u] - x2;
    if(x1 < 0 || x2 < 0 || A[u] < maxw || (x1 > 0 && fa == -1))
    {
        puts("NO");
        exit(0);
    }
    return x1;
}
int main(){
    memset(head,-1,sizeof head);
    n = read();
    for(int i = 1; i <= n; i++)
        scanf("%lld", &A[i]);
    for(int i = 1; i < n; i++)
        addedge(read(),read());
    if(n == 2)
        if(A[1] == A[2])
            printf("YES\n");
        else
            printf("NO\n");
    else
    {
        for(int i = 1; i <= n; i++)
        {
            int num = 0;
            for(int j = head[i]; ~j; j = E[j].nxt)
                if(E[j].v != i)
                    num++;
            if(num > 1){
                dfs(i, -1);
                break;
            }
        }
        printf("YES\n");
    }
    return 0;
}


Measured memory_bytes: 8320
#include<stdio.h>
int main(){
  while(1){
  int n, p1, p2, p3, p4, p5, i;
  int sum=0, max=0, min=0;
  scanf("%d",&n);
  if(n==0){
    break;
  }
  for(i=0; i<n; i++){
  scanf("%d%d%d%d%d",&p1,&p2,&p3,&p4,&p5);
  sum=p1+p2+p3+p4+p5;
  if(max==0){
    max = sum;
  }else if(max!=0 && max<sum){
    max=sum;
  }
  if(min==0){
    min = sum;
  }else if(min!=0 && min>sum){
    min=sum;
  }
  }printf("%d %d\n",max,min);
  }
  return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main(){
  int w, a, b,ans;
  cin >> w >> a >> b;
  if((a<=b&&b<=a+w)||(b<=a&&a<=b+w))ans=0;
  else{
    ans=min(abs(a+w-b),abs(b+w-a));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
void ColorfulTransceivers() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	if (abs(a-c) <= d || (abs(a - b) <= d && abs(b - c) <= d) ) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}
int main() {
	ColorfulTransceivers();
	return 0;
}

Measured memory_bytes: 256
def test():
    s = input()
    k = int(input())
    n = len(s)
    if n == 1:
        print(int(s))
        return
    else:
        if all(int(s[i])==1 for i in range(k)):
            print(1)
            return
        else:
            for i in range(k):
                if int(s[i]) != 1:
                    print(int(s[i]))
                    return


if __name__ == "__main__":
    test()


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

using namespace std;

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

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

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

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

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

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll a, b, c;
        cin >> a >> b >> c;
        cout << max(0LL, c - (a - b)) << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

a = []
for _ in range(3):
	a.extend(LIST())

C = sorted(Counter(a).values())

print("YES" if C == [1, 1, 2, 2] else "NO")


Measured memory_bytes: 5200
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <cassert>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

// defines
#define rrep(i, a, N) for (i=(N)-1;i>=(a);i--)
#define rep(i, a, N) for (i=(a);i<(N);i++)
#define sqr(x) (x) * (x)
#define all(v) (v.begin(), v.end())
#define pb push_back
#define random (rand() << 16 ^ rand())

// Typedefs
typedef pair<int, int> ii;

// constants
const int64_t inf = 1e18+7;
const int64_t mod = 1e9+7;


int main() {
	std::ios::sync_with_stdio(false);
	string s;
	int64_t k;
	int i;

	cin >> s >> k;
	int N = s.size();
	
	rep(i, 0, N) if (s[i] != '1') break;

	if (i < N && k >= (i+1)) cout << s[i] << endl;
	else cout << 1 << endl;

	return 0;
}


Measured memory_bytes: 256
import heapq

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
ok = 10**9
ng = 0
while abs(ng-ok) > 1:
    m = (ok+ng)//2
    cou = 0
    for i in a:
        cou += (i+m-1)//m-1
    if cou <= k:
        ok = m
    else:
        ng = m
print(ok)


Measured memory_bytes: 31188
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    string X;cin>>X;
    stack<char> s;
    int ans = (int)X.size();
    for(auto i = 0; i<X.size();i++){
        
        if(X[i]=='S')s.push(X[i]);
        else if(s.size()!=0 && X[i]=='T' && s.top()=='S'){ans-=2;s.pop();}
        else if(X[i]=='T') s.push(X[i]);
    }
    
    cout<<ans<<endl;

    
    return 0;
}








Measured memory_bytes: 644
#include <bits/stdc++.h>
 
#define REP(i, a, b) for (int i = (int)a; i <= (int)b; i++)
#define fi first
#define sc second
#define pb push_back
#define double long double
#define all(x) x.begin(), x.end()
 
using namespace std;
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int>> vpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<int, int> pii;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
 
const i64 MOD = 998244353;
const i64 INF = 2e15;

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

	int n;
	cin >> n;

	vi a(n);
	REP(i, 0, n-1) cin >> a[i];

	vi dp(n, -1);
	dp[0] = a[0] - 1;

	REP(i, 1, n-1) {
		if (a[i] - 1 >= dp[i-1]) {
			dp[i] = a[i] - 1;
		} else if (a[i] >= dp[i-1]) {
			dp[i] = a[i];
		} else break;
	}

	if (dp[n-1] != -1) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    ll U=3010;
    ll MOD=998244353;
    ll n,s;cin >>n>>s;
    vector<ll>a(n);
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
    }
    vector<vector<ll>>dp(n+1,vector<ll>(U+1,0));
    dp[0][0]=1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < U; ++j) {
            dp[i+1][j]+=dp[i][j]*2%MOD;
            dp[i+1][j]%=MOD;
            if(j+a[i]>U)continue;
            dp[i+1][j+a[i]]+=dp[i][j];
            dp[i+1][j+a[i]]%=MOD;
        }
    }
    cout <<dp[n][s]<<endl;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

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

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

  cout << lcm(a, b) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define rep2(i, s, n) for (int i = s; i < (int)n; i++)
#define all(obj) obj.begin(), obj.end()
#define debug(x) cerr << #x << ":" << x << "\n"
#define vdebug(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int a, b, c;
	int ac = 0, rt = 0, ob = 0;
	while (true) {
		cin >> a >> b >> c;
		if (a == 0 && b == 0 && c == 0) break;
		if (a > b) swap(a, b);
		if (b > c) swap(b, c);
		if (c >= a + b) {
			cout << ac + rt + ob << " " << rt << " " << ac << " " << ob << endl;
			break;
		} else {
			int x = a * a + b * b - c * c;
			if (x > 0) ac++;
			else if (x == 0) rt++;
			else if (x < 0) ob++;
		}
	}
}


Measured memory_bytes: 3088
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <atcoder/all>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N, K;

int main() {
  std::cin >> N >> K;

  atcoder::mcf_graph<ll, ll> G(2*N+2);

  ll s = 2*N, t = 2*N+1;

  G.add_edge( s, t, N*K, INF/2 );

  rep( i, N ) {
    G.add_edge( s, i, K, 0 );
    G.add_edge( N+i, t, K, 0 );
  }

  rep( i, N ) rep( j, N ) {
    ll A;
    std::cin >> A;

    G.add_edge( i, N+j, 1, INF/2-A );
  }

  auto ret = G.flow( s, t, N*K );
  std::cout << N*K*INF/2-ret.second << endl;

  std::vector<std::string> fld( N, std::string( N, '.' ) );

  for( auto e : G.edges() ) {
    if( e.from == s || e.to == t || !e.flow )
      continue;

    fld[e.from][e.to-N] = 'X';
  }

  rep( i, N )
    std::cout << fld[i] << endl;

  return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    ll k; cin>>k;
    int q; cin>>q;
    vll p(n,k);
    rep(i,n) p[i]-=q;
    while(q--){
        int a; cin>>a; a--;
        p[a]++;
    }
    rep(i,n){
        if (p[i]>0){
            cout<<"Yes\n";
        }else{
            cout<<"No\n";
        }
    }
    return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    char s[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) cin >> s[i][j];
    }

    bool can = true;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (s[i][j] == '#') {
                if (s[i - 1][j] == '.' && s[i + 1][j] == '.' && s[i][j - 1] == '.' && s[i][j + 1] == '.') {
                    can = false;
                    break;
                }
            }
        }
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

using ll = long long;

const int offset = 1 << 17;
const int inf =  1 << 29;
int data[2 * offset];


void updata(int k, int x) {
	k += offset - 1;
	data[k] = x;

	while (k > 0) {
		k = (k - 1) / 2;
		data[k] = min(data[2 * k + 1], data[2 * k + 2]);
	}
}

int query(int a, int b, int k, int l, int r) {
	if (b <= l or r <= a) return inf;
	if (a <= l and r <= b) return data[k];
	const int m  = (l + r) / 2;
	return min(query(a, b, 2 * k + 1, l, m), query(a, b, 2 * k + 2, m, r));
}

int cmin[offset];
int d[offset];

int main(void) {
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	s--,t--;

	rep(i,n) cin >> d[i];
	rep(i,n) cmin[i] = i;

	rep(i,m){
		int a,b;
		cin >> a >> b;
		a--,b--;
		cmin[b] = min(cmin[b],a);
	}

	rep(i,s+1) updata(i,0);

	for(int i = s + 1; i < n; ++i) updata(i,query(cmin[i],i,0,0,offset) + d[i]);

	cout << query(t,n,0,0,offset) << endl; 

	return 0;
}

Measured memory_bytes: 4672
Q = int(input())

n = 10**5

import math
def primes():
    sieve = [True] * (n + 1)
    for x in range(2, math.ceil(math.sqrt(n))):
        y = x * 2
        while y <= n:
            sieve[y] = False
            y += x
    return [i for (i, x) in enumerate(sieve[2:], 2) if x]

list_p = primes()
set_p = set(list_p)

tbl = [0] * (n + 1)
for p in list_p:
    tbl[p] = 1 if ((p + 1) // 2) in set_p else 0

import itertools
tbl = list(itertools.accumulate(tbl))

for _ in range(Q):
    l, r = map(int, input().split())
    print(tbl[r] - tbl[l - 1])


Measured memory_bytes: 8212
import sys, re
import math
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	# 
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	# 最大公約数
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

# -*- coding: utf-8 -*-

n, m = MAP()
print(n*m)

Measured memory_bytes: 10628
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func scanInt() int {
	scanner.Scan()
	a, err := strconv.Atoi(scanner.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := scanInt()
	d := map[string]int{}
	for i := 0; i < n; i++ {
		s := scanText()
		d[s]++
	}

	ret := []string{}
	max := 0
	for k, v := range d {
		if v > max {
			max = v
			ret = []string{k}
		} else if v == max {
			ret = append(ret, k)
		}
	}
	sort.Strings(ret)

	for _, k := range ret {
		fmt.Println(k)
	}
}

Measured memory_bytes: 30720
#include<stdio.h>
#include<math.h>

int main(){
  long double N,K,M=0;
  scanf("%Lf %Lf",&N,&K);

  long double i,j;
  if(N>=K){
    M+=N-K+1;
    for(i=1;i<K;i++){
      j=0;
      do{
        j++;
      }while(i*pow(2,j)<K);
      M+=pow(0.5,j);
    }
  }else{
    for(i=1;i<=N;i++){
      j=0;
      do{
        j++;
      }while(i*pow(2,j)<K);
      M+=pow(0.5,j);
    }
  }

  printf("%13.13Lf\n",M/N);

  return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;


#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz(x)           (int)x.size()
#define db(x)           cout<<x<<"\n";

const int N = 2e5 + 5;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

	
//////////////////////////////code//////////////////////////////

void solve()
{
  //  cout << "-------------------" << "\n";
    
   int n,k;
   cin>>n>>k;
   
   vi arr(n+1);
   
   for(int i=1;i<=n;i++) cin>>arr[i];
   
   int dp[n+1][k+1],prefix[n+1][k+1]={0};
   
   for(int i=0;i<=k;i++)
   dp[0][i]=0;
   
   for(int i=0;i<=n;i++)
    dp[i][0]=1;
    
   for(int i=0;i<=n;i++)
   prefix[i][0] = 1;
   
   for(int i=0;i<=k;i++)
   prefix[0][i] = 1;
   
   for(int i=1;i<=n;i++)
   { 
       for(int j=1;j<=k;j++)
       {
           dp[i][j] = (prefix[i-1][j] - ((j > arr[i]) ? prefix[i-1][j-arr[i]-1] : 0) + mod)%mod;
           
           prefix[i][j] = (prefix[i][j-1] + dp[i][j])%mod;
       }
   }
   
   
   cout<<dp[n][k]<<"\n";
    
 //   cout << "-------------------" << "\n";

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

    int t = 1;
    //cin >> t;

    while (t--)
        solve();

}

// check out for following mistakes-
// if using pb operation on vector and then trying to access index..check if sizeof that vec could remain 0 only
// is using prime sieve make sure it fits
// when using factorial template or combinatorics make sure that you edit fillfac fun values and array values


Measured memory_bytes: 161288
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]


X, K,D = map(int, input().split())
X = abs(X)
ans = 0


if(X-K*D>0):
    print(X-K*D)
else:
    ama= X%D
    kai = X//D
    nok = K-kai
    if(nok%2==0):
        print(ama)
    else:
        print(abs(ama-D))


Measured memory_bytes: 68656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ll n, p, ans = 1;
  cin >> n >> p;

  // check_numまでの素数を生成
  ll check_num = (ll)sqrt(p);
  vector<bool> is_prime(check_num + 1, true);
  for (ll i = 0; i <= check_num; i++) {
    if (!is_prime.at(i)) continue;
    if (i == 0 || i == 1) is_prime.at(i) = false;
    if (is_prime.at(i)) {
      for (ll j = 2; j * i <= check_num; j++) {
        is_prime.at(j * i) = false;
      }
    }
  }

  // nを素因数分解↑と併用
  vector<pair<ll, ll>> factor;
  REP(i, check_num + 1) {
    if (is_prime.at(i)) factor.push_back(make_pair(i, 0));
  }
  for (auto &f : factor) {
    while (p % f.first == 0) {
      f.second++;
      p /= f.first;
    }
    if (p == 1) break;
  }
  if (p != 1) {
    factor.push_back(make_pair(p, 1));
  }

  for (auto f : factor) {
    // DEBUG(f.first);
    // DEBUG(f.second);
    if ((ll)floor((double)f.second / n) != 0)
      ans *= (ll)pow(f.first ,(ll)floor((double)f.second / n));
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int main(){
    int n;
    cin>>n;
    int g[n+1][n+1];

    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            g[i][j] = 0;
        }
    }
    
    int u,k;
    for(int i=0; i<n; i++){
        cin>>u>>k;
        for(int j=0; j<k; j++){
            int v;
            cin>>v;
            g[u][v] = 1;
        }
    }
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            cout<<g[i][j];
            if(j%n != 0)cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 1200
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Vector.Unboxed as Vec
import Debug.Trace as De

--getIntList = map read . words <$> getLine


listToTriple abc =(a,b,c)
    where [a,b,c]=abc
main :: IO ()

fir (a,_,_)=a
sec (_,b,_)=b
trd (_,_,c)=c


sol i y z
    | i<0 = ""
    | otherwise=("+ 3 4 6\n"++(rui i)++(pt "+" 6 7 8)++(pt "<" 8 z (y+i))++(pt "<" 8 z 6)++(rui i)++(pt "+" 6 7 7))++(sol (i-1) y z)

rui i
    | i==0 = []
    |otherwise = "+ 6 6 6\n" ++ (rui (i-1))

pt c x y z= c++" "++show(x)++" "++show(y)++" "++show(z)++"\n"

kak i j
    |i==99 = []
    |j==199 = kak (i-1) 229
    |otherwise = (pt "+" i j 8)++(pt "<" 4 8 8)++(pt "+" (i+j) 8 (i+j)) ++ (kak i (j-1))

sai i
    | i==300 = []
    |otherwise = (pt "+" i i i)++(pt "+" i (i-1) (i-1))++ (sai (i-1))
main = do
    putStrLn("4862")
    putStrLn ("+ 0 1 4")
    putStrLn ("< 3 4 4")
    putStrLn ("+ 4 0 0")
    putStrLn ("+ 4 1 1")
    putStr(sol 29 100 0)
    putStrLn("+ 3 3 7")
    putStr(sol 29 200 1)
    putStr(kak 129 229)
    putStr(sai 358)
    putStrLn("+ 2 300 2")


    



Measured memory_bytes: 5392
K,X = map(int,input().split())
R = 1000000 - X
L = X + 1000000
if R <= K:
    for i in range(X-K+1,1000001):
        print(i,end = " ")
elif L <= K:
    for i in range(-1000000,X+K):
        print(i,end = " ")
else:
    for i in range(X-K+1,X+K):
        print(i,end = " ")

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

using namespace std;

int N;

bool rec(int n, list<int>&l){
  if(n == 0)return true;
  auto it = l.begin();
  for(int i = n; i >= 0; --i){
    if(*it == i){
      l.erase(it);
      if(!rec(n - 1, l))return false;
      cout << i << endl;
      return true;
    }
    it++;
    if(it == l.end())return false;
  }
  return false;
}
  
int main(){
  cin >> N;
  list<int> l;
  for(int i = 0 ; i < N; ++i){
    int x; cin >> x; l.push_front(x);
  }
  if(!rec(N, l))cout << -1 << endl; 
  return 0;
}


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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream& os, const set<T>& v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream& os, const map<T,S>& v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "TRACE ON! (Line: " << __LINE__ << ")\n"; auto _stream = istringstream{string{#args}}; d_f(_stream, args); } while(0)
	void d_f(__attribute__((unused)) istringstream& _stream) {}
	template<typename Head, typename... Tails> void d_f(istringstream& _stream, Head H, Tails... T) { string _name; _stream >> _name; if(_name.back() == ',') _name.pop_back(); cerr << "\t" << _name << " <=> [" << H << "]\n"; d_f(_stream, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	char ch;
	cin >> ch;
	cout << ('a' <= ch and ch <= 'z' ? 'a' : 'A') << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3632
## coding: UTF-8
import sys
#import time

#start = time.time()
N, W = map(int,input().split())
l = [list(map(int, input().split())) for _ in range(N)]


dp = [ [sys.maxsize] * (N * 1000) for _ in range(N) ]
for i in range(N):
    for j in range(N * 1000):
        w = l[i][0]
        v = l[i][1]
        if(j == 0):
            dp[i][j] = 0
        elif(j <= v):
            dp[i][j] = min(dp[i-1][j], w)
        else:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-v] + w)
#for k in range(N):
    #print(dp[k][:20])

#print(dp[-1][2999])
#print(dp[-1][3000])
cnt = 0
i = 0
while cnt <= W:
    cnt = dp[-1][i]
    i += 1
    if(i == N*1000):
        i += 2
        break
print(i-2)#0-index , while分の構造上、iが2多くなる



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

#define M 16777216
#define FOUND 1
char H[M];


int getChar( char ch )
{
	if( ch == 'A') {
		return 1;
	} else if( ch == 'C') {
		return 2;
	} else if( ch == 'G') {
		return 3;
	} else if( ch == 'T') {
		return 4;
	}
	return 0;
}

int getKey( char str[] )
{
	int i;
	int key = 0, base = 1;
	for ( i=0; i<strlen( str ); i++ ) {
		key += base*( getChar( str[i] ) );
		base *= 5;
	}
	return key;
}

int find( char str[] )
{
	if( FOUND == H[ getKey( str ) ] ) {
		return FOUND;
	} else {
		return 0;
	}
}

void insert( char str[] )
{
	H[ getKey( str ) ] = FOUND;
	return;
}

int main() 
{
	int i, n;
	char str[14], com[9];	
	
	for ( i=0; i<M; i++ ) {	H[i] = '\0'; }
	
	scanf( "%d", &n );
	int j;
	for ( j=0; j<n; j++ ) {
		scanf( "%s %s", com, str );
		if ( com[0] == 'i' ){
			insert( str );
		} else {
			if( find( str ) ){
				printf("yes\n");
			} else {
				printf("no\n");
			}
		}
	}
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i,a,n) for(int i = a;i < (int)(n);i++)
using namespace std;
typedef long long ll;

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

    double sum = 0;

    irep(i,1,N+1){
        int count = 0;
        ll val = i;
        rep(j,100){
            if(val >= K){
                break;
            }else{
                val *= 2;
                count++;
            }
        }
        sum += (double)1/N*pow(1.0/2.0,count);
    }

    cout << fixed << setprecision(15) << sum << endl;
}

Measured memory_bytes: 256
N = int(input())
A = []
for n in range(N):
    A.append(int(input()))

A_sort = sorted(A)
first = A_sort[-1]
second = A_sort[-2]
if first == second:
    for n in range(N):
        print(first)
else:
    for i in range(N):
        if A[i] == first:
            print(second)
        else:
            print(first)

Measured memory_bytes: 14112
s=str(input())

lens=len(s)
ans=0
list=[]

for i in range(lens):
	if (s[i]=='A')|(s[i]=='T')|(s[i]=='C')|(s[i]=='G'):
		ans=ans+1
	else:
		list.append(ans)
		ans=0
list.append(ans)
print(max(list))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define loop(i, a, b) for (int i = a; i < (int)(b); i++)

struct Key {
    int cost;
    int flag;
};
int dp[1010][4100];

int main() {
    int n, m;
    cin >> n >> m;
    vector<Key> keys;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        int flag = 0;
        rep(j, b) {
            int c;
            cin >> c;
            c--;
            flag |= (1 << c);
        }
        keys.push_back({a, flag});
    }
    const int maxNum = 1000000000; 
    rep(i, 1010) {
        rep(j, 4100) {
            dp[i][j] = maxNum;
        }
    }

    int jMax = pow(2, n);
    dp[0][0] = 0;
    rep(i, m) {
        int cost = keys[i].cost;
        int flag = keys[i].flag;
        rep(j, jMax) {
            if (dp[i][j] == maxNum) {
                continue;
            }
            int nxt = j | flag;
            if (dp[i + 1][j] == maxNum) {
                dp[i + 1][j] = dp[i][j];
            }
            dp[i + 1][nxt] = min(dp[i + 1][nxt], min(dp[i][nxt], dp[i][j] + cost));
        }
    }
    
    int ans = maxNum;
    rep(i, m) {
        if (dp[i][jMax - 1] > 0) {
            ans = min(ans, dp[i][jMax - 1]);
        }
    }
    if (ans == maxNum) {
        cout << -1 << "\n";
    } else {
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 16640
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<functional>
using namespace std;
struct S{int length,ancestor; bool operator>(const S&s)const{return length>s.length;}};

vector<S>v;
S s;
void F(int id)
{
	if(s.ancestor == id)
	{
		v.push_back(s);
		s.length=1;
		s.ancestor=id;
	}
	else
	{
		++s.length;
		s.ancestor=id;
	}
}
int main()
{
	char str[8192];
	scanf("%s",str);
	s.length=0;
	s.ancestor=-1;
	for(int i=0; str[i];)
	{
		if(str[i]=='e')
		{
			F(0);
			i+=3;
		}
		else
		{
			F(1);
			i+=7;
		}
	}
	if(s.ancestor>=0)
		v.push_back(s);
	stable_sort(v.begin(),v.end(),greater<S>());
	puts(v[0].ancestor?"chicken":"egg");
}

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

int main() {
	int n, a[3];
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	int k = a[0];
	for(int i = 1; i < n; i++ ) k = max(k, a[i]);
	for(int i = 1; i <= k/2 ; i++){
		int cnt = 0;
		for(int j = 0; j < n; j++){
			if( a[j] % i == 0 ) cnt++;
		}
		if( cnt == n ) cout << i << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 59);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------
ll f(ll a, ll b){
    return a / b;
}

// 最大公約数を計算 GCD
// 最小公倍数を計算 LCM
ll llgcd(ll a, ll b){
    if(b == 0){
        return a;
    }
    return llgcd(b, a % b);
}
ll lllcm(ll a, ll b){
    if(a == 0 || b == 0){
        return 1;
    }
    return a / llgcd(a, b) * b;
}

// main -----------------------------------------------

int main() {
    ll n;
    cin >> n;
    vector<P> ba(n);
    REP(i, n){
        ll a, b;
        cin >> a >> b;
        ba[i].first  = b;
        ba[i].second = a;
    }

    sort(ba.begin(), ba.end());

    ll now = 0;
    REP(i, n){
        now += ba[i].second;
        if(now > ba[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 6432
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}

bitset<26000> bset[100][100];
int c[100][100];

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int h,w;
  cin>>h>>w;
  rep(i,h){
    rep(j,w){
      cin>>c[i][j];
    }
  }
  rep(i,h){
    rep(j,w){
      int b;
      cin>>b;
      c[i][j]-=b;
      c[i][j]=abs(c[i][j]);
    }
  }

  int bi=13000;
  bset[h-1][w][bi]=1;
  rrep(i,h-1){
    rrep(j,w-1){
      bset[i][j]|=(bset[i+1][j]<<c[i][j]);
      bset[i][j]|=(bset[i+1][j]>>c[i][j]);
      bset[i][j]|=(bset[i][j+1]<<c[i][j]);
      bset[i][j]|=(bset[i][j+1]>>c[i][j]);
      
    }
  }

  int ans=inf;
  rep(i,26000){
    if(bset[0][0][i]) ans=min(ans,abs(i-bi));
  }
  cout<<ans<<endl;


}

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

using namespace std;

int main() {
  int  x, y, s;
  
  while (true) {
    cin >> x >> y >> s;
    if (x + y + s == 0) {
      break;
    }
    
    int ans = 0;
    for (int i = 1; i < 2 * s; i++) {
      for (int j = 1; j < 2 * s; j++) {
        int t = (int)((i * (100 + x)) / 100) + (int)((j * (100 + x)) / 100);
        if (t == s) {
          int u = (int)((i * (100 + y)) / 100) + (int)((j * (100 + y) )/ 100);
          ans = max(ans, u);
        }   
      }
    }
    cout << ans << endl;
  }
  
  
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> pi;
#define F first
#define S second
#define PB push_back

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

const int MOD = 1000000007;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    rep (i, n) {
        cin >> a[i];
        a[i]--;
    }
    int now = 0;
    int cnt = 0;
    while (cnt < n) {
        now = a[now];
        cnt++;
        if (now == 1) {
            cout << cnt << endl;
            return 0;
        }
    }
    cout << -1 << endl;
} 


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s = "abc";
  rep(i, 3) cin >> s[i];
  int n = stoi(s);
  if (n%4)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
/*
* Author:sam51305
*/
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define endl '\n'
#define f first
#define s second
#define mp make_pair
#define ll long long
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pb push_back
#define ary array

#define Yes cout << "Yes" <<endl;
#define No cout << "No" << endl;
int main() {
    fastio
    int A,B,C;
    cin >> A >> B >> C;
    cout << C << " " << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        d = in.nextInt();
        g = in.nextInt();
        p = new int[d];
        c = new int[d];
        for (int i = 0; i < d; i++) {
            p[i] = in.nextInt();
            c[i] = in.nextInt();
        }
        visited = new boolean[d];

        System.out.println(backtrack(0));

    }

    static int[] p;
    static int[] c;
    static boolean[] visited;
    static int d;
    static int g;

    private static int backtrack(int sum) {
        if (sum >= g) {
            return 0;
        }
        int best = Integer.MAX_VALUE / 2;
        for (int j = 0; j < d; j++) {
            if (!visited[j]) {
                visited[j] = true;
                best = Math.min(best, Math.max(1, Math.min((g - sum) / ((j + 1) * 100), p[j])) + backtrack(sum + (j + 1) * 100 * p[j] + c[j]));
                visited[j] = false;
            }
        }
        return best;
    }
}


Measured memory_bytes: 22100
#include "bits/stdc++.h"
using namespace std;

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

  vector<int> H(N, 0);
  vector<vector<int>> Graph(N, vector<int>(0));

  vector<int> Founds(0);
  vector<set<int>> Group(N);
  vector<bool> Visited(N, false);

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

  for (int i = 0; i < M; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }

  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (Visited[i])
      continue;
    int cur = H[i];
    bool res = true;
    for (int j : Graph[i]) {
      if (cur <= H[j]) {
        res = false;
        break;
      }
    }
    if (res)
      cnt++;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 13556
def main():
    n = int(input())
    hs = list(map(int, input().split()))

    INF = 10 ** 12
    dp = [INF] * n
    dp[0] = 0

    for i in range(0, n):
        if i + 1 < n:
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(hs[i + 1] - hs[i]))
        if i + 2 < n:
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(hs[i + 2] - hs[i]))

    print(dp[-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 84084
#include<stdio.h>

int main(void){
    int h,m,s,x,a;
    
    scanf("%d",&x);
    
    h=x/3600;
    a=x%3600;
    m=a/60;
    s=a%60;
    
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  ll k = a+b;
  if(k % 2 == 0) cout << k / 2;
  else cout << "IMPOSSIBLE";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AGC013
{
    public class B
    {
        private void Run()
        {
            var input = Console.ReadLine().Trim().Split();
            var N = int.Parse(input[0]);
            var M = int.Parse(input[1]);

            var edges = Enumerable.Range(0, N).Select(_ => new List<int>()).ToArray();
            while (M-- > 0)
            {
                input = Console.ReadLine().Trim().Split();
                var A = int.Parse(input[0]) - 1;
                var B = int.Parse(input[1]) - 1;
                edges[A].Add(B);
                edges[B].Add(A);
            }

            var hasEdgeIndex = Enumerable.Range(0, N).FirstOrDefault(i => edges[i].Count > 0);
            var head = new List<int>();
            var tail = new List<int>();
            var used = new bool[N];

            used[hasEdgeIndex] = true;
            Action<List<int>, int> dfs = null;
            dfs = (list, current) =>
            {
                foreach (var e in edges[current])
                {
                    if (used[e]) { continue; }
                    used[e] = true;
                    list.Add(e);
                    dfs(list, e);
                    break;
                }
            };
            dfs(head, hasEdgeIndex);
            dfs(tail, hasEdgeIndex);

            var result = head.AsEnumerable().Reverse().Concat(new[] { hasEdgeIndex }).Concat(tail).Select(i => i + 1).ToArray();
            Console.WriteLine(result.Length);
            Console.WriteLine(string.Join(" ", result));
        }

        public static void Main()
        {
            var old = Console.Out;
            using (var writer = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false })
            {
                Console.SetOut(writer);
                new B().Run();
                Console.Out.Flush();
                Console.SetOut(old);
            }
        }
    }
}


Measured memory_bytes: 43788
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	long long int n;
	cin >> n;
	long long int a[n+1] = {0};
	long long int b[n] = {0};
	for(int i=0;i<=n;i++)
		cin >> a[i];
	for(int i=0;i<n;i++)
		cin >> b[i];
	long long int sum = 0;
	for(int i = n-1;i>=0;i--){
		if(b[i] <= a[i+1])
			sum += b[i];
		else
			{
				sum += a[i+1];
				b[i] = b[i] - a[i+1];
				if(b[i] >= a[i])
					{
						sum += a[i];
						a[i] = 0;
					}
				else
					{
						sum += b[i];
						a[i] = a[i] -  b[i];
					}					
			}
	}
	cout << sum << endl;
}

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

const int INF = 2e9;

int main(){
    int n,a;
    cin >> n;
    vector<int> b(100000);
    rep(i,n){
        cin >> a;
        b[a]++;
    }
    int sum = b[0] + b[1] + b[2];
    int ans = sum;
    for(int i = 3;i < 100000;i++){
        sum += b[i];
        sum -= b[i - 3];
        ans = max(ans,sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3752
N=int(input())
dp=[N]*(N+1)
dp[0]=0
for i in range(1,N+1):
    dp[i]=min(dp[i],dp[i-1]+1)
    pow6 = 1
    while i>=pow6:
        dp[i]=min(dp[i],dp[i-pow6]+1)
        pow6*=6
    pow9 = 1
    while i>=pow9:
        dp[i]=min(dp[i],dp[i-pow9]+1)
        pow9*=9
print(dp[N])

Measured memory_bytes: 3828