akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int x,y;cin >> x >> y;
    rep(a,x+1){
        int b = x-a;
        if(b < 0)break;
        if(2*a + 4*b == y){
            cout << "Yes" << endl;
            return 0;
        }

    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
function bomb(y,x,color){
   var dy=[-1,0,0,1];
   var dx=[0,-1,1,0];
   for(var i=0;i<4;i++){
      var yy=y+dy[i];
      var xx=x+dx[i];
      if(yy<0 || xx<0 || yy>=12 || xx>=6)continue;
      if(yx[yy][xx]==color) {
         CNT++;
         if(CNT==4)p.push([yy,xx]);
         yx[yy][xx]=color+CNT;
         bomb(yy,xx,color);
      }
   }
}
function BOMB(y,x,color){
   var dy=[-1,0,0,1];
   var dx=[0,-1,1,0];
   for(var i=0;i<4;i++){
      var yy=y+dy[i];
      var xx=x+dx[i];
      if(yy<0 || xx<0 || yy>=12 || xx>=6)continue;
      if(yx[yy][xx]==color){
         yx[yy][xx]=".";
         BOMB(yy,xx,color);
      }else if(yx[yy][xx]=="O"){
         yx[yy][xx]=".";
      }
   }
}
function up(y,x){
   var yy=y;
   while(y>0){
      y--;
      if(yx[y][x]!="."){
         yx[yy][x]=yx[y][x];
         yx[y][x]=".";
         break;
      }
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
for(var I=0;I<n;I++){
   var yx=[];
   for(var i=0;i<12;i++){
      var arr=(Arr.shift()).split("");
      yx.push(arr);
   }
   var result=0;  
   while(true){
        var p=[];
        var CNT;
         for(var i=0;i<12;i++){
               for(var j=0;j<6;j++){
                  if(yx[i][j]=="R"){CNT=1;yx[i][j]="R"+CNT;bomb(i,j,"R");}
                  if(yx[i][j]=="G"){CNT=1;yx[i][j]="G"+CNT;bomb(i,j,"G");}
                  if(yx[i][j]=="B"){CNT=1;yx[i][j]="B"+CNT;bomb(i,j,"B");}
                  if(yx[i][j]=="Y"){CNT=1;yx[i][j]="Y"+CNT;bomb(i,j,"Y");}
                  if(yx[i][j]=="P"){CNT=1;yx[i][j]="P"+CNT;bomb(i,j,"P");}
               }
         }
         for(var i=0;i<12;i++){
            for(var j=0;j<6;j++){
               yx[i][j]=yx[i][j].slice(0,1);
            }
         }
         if(p.length==0)break;
         result++; 
         p.forEach(function(v){
            var i=v[0];
            var j=v[1];
            var color=yx[i][j];
            BOMB(i,j,color);
         });
         for(var i=11;i>0;i--){
            for(var j=0;j<6;j++){
               if(yx[i][j]==".")up(i,j);
            }
         }
   }
   console.log(result);
}

Measured memory_bytes: 9804
package main
import "fmt"
func main() {
  const mod int64 = 1000000007
  var n int
  var s1,s2 string
  fmt.Scan(&n)
  fmt.Scan(&s1)
  fmt.Scan(&s2)
  var p []int = []int{}
  for i:=0;i<n; {
    if s1[i:i+1] == s2[i:i+1] {
      p = append(p,0)
      i++
    } else {
      p = append(p,1)
      i += 2
    }
  }
  var m int64 = 3
  if p[0] == 1 { m = 6 }
  for i:=1;i<len(p);i++ {
    if p[i-1] == 0 && p[i] == 0 || p[i-1] == 0 && p[i] == 1 {
      m *= 2
    } else if p[i-1] == 1 && p[i] == 1 {
      m *= 3
    }
    m %= mod
  }
  fmt.Println(m)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 55;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A[NMAX],B,C,D,E;
ll dp[NMAX][2] = {};

string S;
vec v;

ll ans = {};

void solve(){
  // main algorithm
  dp[0][0] = 1;
  for (int i = 1; i <= N; ++i)
  {
    if(A[i] % 2) {
      dp[i][0] = dp[i-1][0] + dp[i-1][1];
      dp[i][1] = dp[i-1][1] + dp[i-1][0];
    }
    else {
      dp[i][0] = 2 * dp[i-1][0];
      dp[i][1] = 2 * dp[i-1][1];
    }
  }
  ans = dp[N][K];
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> K;
  for (int i = 0; i < N; ++i)
  {
    scanf("%lld", &A[i]);
  }
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
/**
*    created: 13.05.2020 18:38:47
**/
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#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++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int n, m, p[10];
    vector<int> s[10];

    cin >> n >> m;
    rep(i,m) {
        int k; cin >> k;
        s[i].resize(k);
        rep(j,k) cin >> s[i][j];
    }
    rep(i,m) cin >> p[i];
    int ans = 0; //場合の数
    for (int bit = 0; bit < (1 << n); bit++) {
        int ok = true; //ansをインクリメントするかのbool
        rep(i,m) {
            int sum = 0; //点灯しているスイッチの個数
            for (int j : s[i]) {
                if ((bit >> (j - 1)) & 1) sum++;
            }
            if (sum % 2 != p[i]) {
                ok = false;
                break;
            }
        }
        if (ok) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;


long long int N, M, K, H, W, L, R;

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

	cin >> N;
	while (N) {
		vector<string>v(N);
		M = 0;
		for (int i = 0; i < N; i++) {
			cin >> v[i];
			M = max(M, (long long int)v[i].size());
			int r = -1;
			for (int j = 0; j < v[i].size(); j++) {
				if (v[i][j] == '.')r = j;
			}
			v[i][r] = '+';
		}
		for (int i = 0; i < M; i++) {
			int u = -1;
			for (int j = 0; j < N; j++) {
				if (v[j].size() <= i) {
					u = -1;
					continue;
				}
				if (v[j][i] == '+') {
					if (u == -1) {
						u = j;
					}
					else {
						for (int k = u + 1; k < j; k++) {
							v[k][i] = '|';
						}
						u = j;
					}
				}
				else if (v[j][i] != '.') {
					u = -1;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < v[i].size(); j++) {
				if (v[i][j] == '.')v[i][j] = ' ';
			}
		}
		for (auto i : v) {
			cout << i << endl;
		}
		cin >> N;
	}
	return 0;
}


Measured memory_bytes: 3516
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
ll t = 1, tt;
const ll N=100005;
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll mult(ll x,ll y){return (x*y)%hell;}
inline ll powMod(ll base,ll expo){
	ll res=1;
	while(expo){
		if(expo&1)res=mult(res,base);
		base=mult(base,base);
		expo>>=1;
	}
	return res;
}
void solve(){
	ll n, k, ans=0;
	cin>>n>>k;
	vector<ll> dp(k+5,0);
	for(ll i=k;i>=1;i--){
		ll cnt=1, tmp=0;
		for(ll j=2*i;j<=k;j+=i){
			cnt++;
			tmp=add(tmp,dp[j]);
		}
		dp[i]=add(powMod(cnt,n),hell-tmp);
		ans=add(ans,mult(i,dp[i]));
	}
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3992
from collections import defaultdict, deque

v, n = map(int, input().split())
es = [[int(x) for x in input().split()] for _ in range(n)]

outs = defaultdict(list)
ins = defaultdict(int)
for v1, v2 in es:
    outs[v1].append(v2)
    ins[v2] += 1

q = deque(v1 for v1 in range(v) if ins[v1] == 0)
res = []
while q:
    v1 = q.popleft()
    res.append(v1)
    for v2 in outs[v1]:
        ins[v2] -= 1
        if ins[v2] == 0:
            q.append(v2)

for i in res:
    print(i)


Measured memory_bytes: 15616
import math
import itertools
import fractions
import heapq
import collections
import bisect
import sys

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

n,m = LI()

l = [False]*n
c = [0]*n
ans=0
for i in range(m):
    p,s = LS()
    if s=="AC":
        l[int(p)-1]=True

    else:
        if l[int(p)-1]==False:
            c[int(p)-1]+=1

for i in range(n):
    if l[i]:
        ans+=c[i]

print(l.count(True),ans)

Measured memory_bytes: 6700
#include <stdio.h>
#define maxn 200010
int n,k,a[maxn];
int judge(int x){
	int i,cnt=0;
	for(i=1;i<=n;i++)
		cnt+=(a[i]-1+x)/x-1;
	if(cnt>k)return 0;
	else return 1;
}
int main(){
	int i,l,r,mid;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	l=0,r=1000000000;
	while(l+1<r){
		mid=(l+r)/2;
		if(judge(mid))r=mid;
		else l=mid;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 2460
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9)+1;
const ll mod = ll(1e9)+7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

ll power(ll a, ll b){
    a %= mod;
    if(b == 0){
        return 1;
    }
    ll ans = power(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans %= mod;
        ans *= power(i + 1, mod - 2);
        ans %= mod;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    pf((n + 1) / 2);
    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;
//using P = pair<int, int>;

int main() {
    int n; ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) {
        cin >> a[i];
        a[i]--;
    }

    vector<int> g(n,-1);
    int ans = 0;
    int i = 0, cnt = 0, pre;
    while (1) {
        if (g[i] == -1) {
            g[i] = cnt;
            cnt++;
            pre = cnt;
            i = a[i];
        } else {
            ll index = (k-g[i])%(pre-g[i]);
            index += g[i];
            rep(j,n) if (g[j] == index) ans = j+1;
            break;
        }
        if (cnt == k) {
            ans = i+1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5636
#include <iostream>
#include <cstdint>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <random>

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++)

const int MAX_COUNT = 100110;
int dp[3][MAX_COUNT];

struct Happiness {
    int a, b, c;
};

int solve(int n, vector<Happiness> h) {
    dp[0][0] = h[0].a;
    dp[1][0] = h[0].b;
    dp[2][0] = h[0].c;

    loop(i, 1, n) {
        auto hh = h[i];
        dp[0][i] = max(dp[1][i - 1] + hh.a, dp[2][i - 1] + hh.a);
        dp[1][i] = max(dp[0][i - 1] + hh.b, dp[2][i - 1] + hh.b);
        dp[2][i] = max(dp[0][i - 1] + hh.c, dp[1][i - 1] + hh.c);
    }
    int ret = dp[0][n - 1];
    ret = max(ret, dp[1][n - 1]);
    ret = max(ret, dp[2][n - 1]);
    return ret;
}


int main() {
    int n;
    vector<Happiness> h;
    cin >> n;
    rep(i, n) {
        int a, b, c;
        cin >> a >> b >> c;
        h.push_back({a, b, c});
    }
    int ans = solve(n, h);
    cout << ans << "\n";
}


Measured memory_bytes: 3956
#a,b,c,dをスペースで区切って入力したものをa,b,c,d,に代入
a,b,c,d = map(int,input().split())
#AとCの差がDより大きくて、AとBの差かBとCの差がDより大きければNo
if abs(c - a) > d and(abs(b-a) > d or abs(c-b) > d):
    print("No")
#そうでなければYes
else:
    print("Yes")

Measured memory_bytes: 9160
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second

signed main(){
  int h,w,H,W;
  cin>>h>>w>>H>>W;
  h--;w--;H--;W--;
  int a=H;
  int b=h-H;
  int c=W;
  int d=w-W;
 // cout<<a<<b<<c<<d<<endl;
  if((a%2==0&&b%2==0)&&(c%2&&d%2)){
    cout<<"No"<<endl;
  }
  else if((c%2==0&&d%2==0)&&(a%2&&b%2)){
    cout<<"No"<<endl;
  }
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
int n,N,a[5],i,nn;
long long t;
int main(){
	cin>>n;nn=n;
	for(i=0;i<n;i++)cin>>a[i];
	sort(a,a+n,greater<int>());
	for(i=0;i<n;i++){
		if(a[i]>=4){
			t+=a[i];
			a[i]=0;
			for(int j=i+1;j<n;j++)a[j]--;
			N++;
		} else break;
	}
	for(i=N+1;i<nn;i++)if(a[i]<=1)n--;
	n=n-N;
	if(a[N]==1)t++;
	else if(a[N]==2){
		if(n==1)t+=2;
		if(n==2||n==3)t+= 3;
		if(n==4||n==5)t+= 4;
	} else if(a[N]==3){
		if(n==1)t+=3;
		if(n==2){
			if(a[N+1]==2)t+=4;
			else t+=5;
		}
		if(n==3){
			if(a[N+1]==2)t+=4;
			else if(a[N+2]==2)t+=5;
			else t+=6;
		}
		if(n==4){
			if(a[N+1]==2)t+=4;
			else if(a[N+2]==2)t+=5;
			else t+=6;
		}
		if(n==5){
			if(a[N+1]==2||a[N+2]==2)t+=5;
			else if(a[N+3]==2||a[N+4]==2)t+=6;
			else t+=7;
		}
	}
	cout<<t<<endl;
}

Measured memory_bytes: 1180
#include<stdio.h>
#include<math.h>
#include <stdlib.h>


int main(){

    int n;
    scanf("%d", &n);

    int *a = (int*)calloc(n + 1, sizeof(int));
    int i;

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

    int ans = 0, cnt;
    for(i = 1; i <= n; ++i){
        cnt = 0;
        while(a[i] == i && i <= n){
            cnt++;
            i++;
        }
        if(cnt%2==1){
            ans += (cnt + 1)/2;
        } else {
            ans += cnt/2;
        }
    }


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

Measured memory_bytes: 512
N, K = map(int, input().split())
P = list(map(int, input().split()))
P = [p - 1 for p in P]
C = list(map(int, input().split()))

vis = [False] * N
ans = [-float('inf')] * N

for root in range(N):
    if vis[root]:
        continue
    vis[root] = True

    cycle = [root]
    costs = [C[root]]
    u = P[root]
    vis[u] = True
    while u != root:
        cycle.append(u)
        costs.append(C[u])
        u = P[u]
        vis[u] = True

    # print('-' * 10)
    # print(cycle)
    # print(costs)

    L = len(cycle)
    S = sum(costs)
    for i, v in enumerate(cycle):
        cnt = 0
        for step in range(1, min(L, K) + 1):
            cnt += costs[(i + step) % L]
            val1 = cnt
            val2 = cnt + (K - step) // L * S
            ans[v] = max(ans[v], val1, val2)

print(max(ans))



Measured memory_bytes: 69336
/**
 *     author: qodjf
 *     created: 04.17.2020 00:24:12
 */
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;

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

int N;
const int MAXN = 2e5 + 5;
int g[MAXN];
int solve() {
  vector<bool> vis(N + 5, false);
  queue<int> que;
  que.push(1);
  vis[1] = true;
  int d = 0;
  while (!que.empty()) {
    for (int _ = que.size(); _; _--) {
      int u = que.front();
      que.pop();
      if (u == 2) return d;
      int v = g[u];
      if (!vis[v]) {
        vis[v] = true;
        que.push(v);
      }
    }
    d++;
  }
  return -1;
}

int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> g[i];
  }
  cout << solve() << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int n;
	cin >> n;

	vi p = { 11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381,1451,1471,1481,1511,1531,1571,1601,1621,1721,1741,1801,1811,1831,1861,1871,1901,1931,1951,2011,2081,2111,2131,2141,2161,2221,2251,2281,2311,2341,2351,2371,2381,2411,2441,2521,2531,2551,2591,2621,2671,2711,2731,2741 };

	cout << 2 << ' ';
	rep(i, n-1) {
		cout << p[i] << ' ';
	}

	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

int n,m;
int k[11];
int s[11][11];
int p[11];

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>k[i];
		for(int j=0;j<k[i];j++){
			cin>>s[i][j];
			s[i][j]--;
		}
	}
	for(int i=0;i<m;i++){
		cin>>p[i];
	}
	int ans=0;
	for(int i=0;i<(1<<n);i++){
		bool tentou = true;
		for(int j=0;j<m;j++){
			int cnt = 0;
			for(int kk=0;kk<k[j];kk++){
				if(0 < (i & (1<<s[j][kk]))) cnt++;
			}
			//cout<<i<<" "<<cnt<<endl;
			if((cnt % 2) != p[j])  tentou = false;
		}
		if(tentou) ans++;
	}
	cout<<ans<<endl;
	return 0;

}

Measured memory_bytes: 256
import itertools
N,M = map(int,input().split())
K = [0]*M
S = [[0] *N for _ in range(M)]
for i in range(M):
    tmp = list(map(int,input().split()))
    K[i] = tmp[0]
    for s in tmp[1:]:
        S[i][s-1] = 1
P = list(map(int,input().split()))

ptns = list(itertools.product((0,1),repeat=N))
ans = 0
# 全てのON/OFFパターン
for p in ptns:
    # 全ての電球
    for i in range(M):
        # ONになっているスイッチ
        on_count = 0
        for j in range(N):
            on_count += S[i][j] and p[j]
        if on_count%2 != P[i]:
            break
        
    else:
        # print(p)
        ans += 1
print(ans)


Measured memory_bytes: 41200
#include<bits/stdc++.h>
#define re register
#define inc(i,j,k) for(re int i=j;i<=k;i++)
using namespace std;
const int N=1e5+5;
int a[N],fa[N],head[N],cnt,b[N],p;
int getfa(int x){return fa[x]==x?x:fa[x]=getfa(fa[x]);}
struct egde{
	int to,nxt;
}e[N<<1];
void add(int a,int b){
	e[++cnt].to=b;
	e[cnt].nxt=head[a];
	head[a]=cnt;
}
void dfs(int u,int type){
	a[u]=type;
	for(re int i=head[u];i;i=e[i].nxt){
		int v=e[i].to;
		if(v==fa[u]) continue;
		fa[v]=u;
		dfs(v,-type);
		a[u]+=a[v];
	}
}
int main(){
	int n,m,rt=1,rs=1,ans=0;
	scanf("%d%d",&n,&m);
	inc(i,1,n) fa[i]=i;
	inc(i,1,m){
		int x,y;
		scanf("%d%d",&x,&y);
		if(getfa(x)!=getfa(y)) fa[fa[x]]=fa[y];
		else{rt=x,rs=y;continue;}
		add(x,y),add(y,x);
	}
	fa[rt]=0,dfs(rt,1);
	if(n==m){
		for(re int i=rs;i;i=fa[i]) b[++p]=a[i];
		if(p&1){
			if(a[rt]&1) return puts("-1"),0;
			for(re int i=rs;i;i=fa[i]) a[i]-=a[rt]>>1;
		}
		else{
			if(a[rt]) return puts("-1"),0;
			sort(b+1,b+p+1);
			for(re int i=rs;i;i=fa[i]) a[i]-=b[p>>1]; 
		}
	}
	else if(a[rt]) return puts("-1"),0;
	inc(i,1,n) ans+=abs(a[i]);
	printf("%d",ans);
}

Measured memory_bytes: 8064
L, R = map(int, input().split())
mod = 2019
left = L // mod
right = R // mod
l_mod = L % mod
r_mod = R % mod

if left != right or l_mod == 0 or r_mod == 0:
    print(0)
else:
    ans = float('inf')
    for i in range(l_mod, r_mod):
        for j in range(i + 1, r_mod + 1):
            ans = min(ans, (i * j) % mod)
    print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int ar[101],sum[100005];
ll dp[105][100005];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>ar[i];
    }
    dp[0][0] = 1;

    for(int i=1;i<=n;i++)
    {
        sum[0] = dp[i-1][0];
        for(int p=1;p<=k;p++) sum[p] = (sum[p-1] + dp[i-1][p])%mod;
        for(int t=0;t<=k;t++)
        {
            ll tot = sum[t];
            ll unreach = t-ar[i-1]-1;
            if(unreach>=0)
            {
                tot = (tot-sum[unreach]+mod)%mod;
            }
            dp[i][t] = tot;
        }
    }
    cout<<dp[n][k]<<endl;
}


Measured memory_bytes: 79744
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9

using namespace std;

ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 

// max({a, b, c, d})

vector<ll>adj[200005];
ll update[200005];
ll ans[200005];

int binaryToDecimal(string n) 
{ 
    string num = n; 
    int dec_value = 0; 
  
    // Initializing base value to 1, i.e 2^0 
    int base = 1; 
  
    int len = num.length(); 
    for (int i = len - 1; i >= 0; i--) { 
        if (num[i] == '1') 
            dec_value += base; 
        base = base * 2; 
    } 
  
    return dec_value; 
} 

bool isPerfectSquare(long double x) 
{   
  // Find floating point value of  
  // square root of x. 
  long double sr = sqrt(x); 
  
  // If square root is an integer 
  return ((sr - floor(sr)) == 0); 
} 

int main()
{
    ll x, a;
    cin >> x >> a;

    if(x < a)
        cout << 0 << "\n";
    else cout << 10 << "\n";
}




Measured memory_bytes: 6016
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long a[44],L,R;
int k,n;
vector<long long>P[22];
main()
{
	cin>>n>>k>>L>>R;
	int N=(n+1)/2;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<1<<N;i++)
	{
		long long sum=0;
		for(int j=0;j<N;j++)if(i&(1<<j))sum+=a[j];
		P[__builtin_popcount(i)].push_back(sum);
	}
	for(int i=0;i<=N;i++)sort(P[i].begin(),P[i].end());
	long long cnt=0;
	for(int i=0;i<1<<(n-N);i++)
	{
		long long sum=0;
		int K=k-__builtin_popcount(i);
		if(K<0||K>N)continue;
		for(int j=0;j<n-N;j++)if(i&(1<<j))sum+=a[N+j];
		cnt+=distance(lower_bound(P[K].begin(),P[K].end(),L-sum),
		upper_bound(P[K].begin(),P[K].end(),R-sum));
	}
	cout<<cnt<<endl;
}



Measured memory_bytes: 12328
//pragma GCC optimize("Ofast")
//pragma GCC optimize("unroint-loops")
//pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(int i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( int i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (int) a.size()
#define aint(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
//#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii ;
typedef vector<int>  vi ;
typedef vector<ii> vii ;


const int MAX = 3e3+6;
const ll inf = 5e18;
ll mod=998244353;

ll a[12][1010];

ll cant(ll y1,ll x1,ll y2,ll x2){
	return a[x1][y1]-a[x1][y2]-a[x2][y1]+a[x2][y2];
}


int main(){
	fastio;
	ll h,w,k;
	string s;
	cin>>h>>w>>k;
	f(i,1,h+1){
		cin>>s;
		f(j,1,w+1){
			a[i][j] =  (s[j-1]-'0'); 
		}
	}
	f(i,1,h+1){
		f(j,1,w+1) a[i][j]+=(a[i][j-1]+a[i-1][j]-a[i-1][j-1]);
	}
//	cout<<" ::"<<cant(1,5,0,0)<<endl;
	ll ans=1e9;
	f(mask,0,1<<(h-1) ){
		vi ele;
		ele.push_back(0);
		f(i,0,h-1){
			if(mask&(1<<i)){
				ele.push_back(i+1);
			}
		}
		ele.push_back(h);
		ll t = ele.size();
		ll c=t-2,ant=0,cc=0;

		f(i,1,w+1){
			ll go=0,cut=0;
			f(j,1,t){
				ll num = cant(i,ele[j],ant,ele[j-1]); 
//				cout<<num<<" //"<<endl;
				if(num>k){
					cut=1;
					break;
				}
			}
			if(cut){	
				f(j,1,t){
					ll num=cant(i,ele[j],i-1,ele[j-1]);
					if(num>k) go=1;
				}
			}
			if(go) {
				c=1e9;
				break;
			}
			if(cut) {
//				cout<<i-1<<" ";
				ant=i-1,cc++;
			}
		}
//		cout<<endl;
//		cout<<c<<" "<<cc<<endl;
		c+=cc;
		ans=min(ans,c);
	}
	cout<<ans<<endl;

}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

template <typename T> inline void print(T val) { cout << val << '\n'; }

template <typename Iterator> inline void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; it = next(it)) {
    cout << *it << ' ';
  }
  cout << '\n';
}

template <class T> inline T square(T x) {
  T result;
  result = x * x;
  return result;
};

#ifdef LOCAL
#define DBG_MACRO_NO_WARNING
#include <dbg.h>
#else
#define dbg(...) 0
#endif

const int MOD = 1e9 + 7;
const int INF = 1e9 + 5;

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

#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  auto start = chrono::steady_clock::now();
#endif

  int n;
  cin >> n;

  vector<int> a(n + 1);
  a[0] = 0;

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

  int sum = 0;

  for (auto i = 0; i <= n; ++i) {
    if (i == 0) {
      sum += abs(a[n] - a[0]);
      continue;
    }

    sum += abs(a[i] - a[i - 1]);
    dbg(i, sum);
  }

  for (auto i = 1; i <= n; ++i) {
    if (i == n) {
      print(sum - abs(a[n] - a[n - 1]) - abs(a[n] - a[0]) +
                abs(a[n - 1] + a[0]));

      continue;
    }
    print(sum - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) +
          abs(a[i - 1] - a[i + 1]));

    dbg(sum - abs(a[i - 1] - a[i]) - abs(a[i] - a[i + 1]) +
        abs(a[i - 1] - a[i + 1]));
  }

  dbg(sum);

#ifdef LOCAL
  auto end = chrono::steady_clock::now();
  auto diff = end - start;

  cout << "Duration: " << chrono::duration<double, milli>(diff).count() << " ms"
       << '\n';
#endif

  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#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() {
  int N; cin >> N;
  int s[N]; rep(i, N) cin >> s[i];
  sort(s, s+N);

  int result = 0; rep(i, N) result += s[i];
  if (result%10==0) {
    rep(i, N) {
      if (s[i]%10!=0) { result -= s[i]; break; }
      if (i==N-1) result = 0;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

const inf = 1 << 60

func main() {
	n := getInt()
	hs := getIntSlice(n)

	dp := make([]int, n)
	for i := range dp {
		dp[i] = inf
	}
	dp[0] = 0

	for i := 1; i < n; i++ {
		dp[i] = min(dp[i], dp[i-1]+abs(hs[i]-hs[i-1]))
		if i > 1 {
			dp[i] = min(dp[i], dp[i-2]+abs(hs[i]-hs[i-2]))
		}
	}

	fmt.Println(dp[n-1])
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func min(ns ...int) int {
	min := ns[0]
	for i := 1; i < len(ns); i++ {
		if min > ns[i] {
			min = ns[i]
		}
	}
	return min
}

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

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 2688
A,B=map(int,input().split())

def eo_of_ones(a):
  if (a+1)%4==1 or (a+1)%4==0:
    l='0'
  else:
    l='1'
  for i in range(1,50):
    l=str((max(0,((a+1)%(2**(i+1)))-(2**i)))%2)+l
  return list(l)

def solve():
  ans=0
  if A==B:
    ans=B
  elif A==0:
    l_b=eo_of_ones(B)
    for i in range(50):
      ans+=int(l_b.pop())*(2**i)
  else:
    l_a=eo_of_ones(A-1)
    l_b=eo_of_ones(B)
    for i in range(50):
      ans+=((int(l_b.pop())+int(l_a.pop()))%2)*(2**i)
      
  print(ans)

solve() 


Measured memory_bytes: 3064
//Let's play :)
#include<bits/stdc++.h>
using namespace std;

#define tarzan ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long 

int rr[] = {0, 1, 1, 1, 0, -1, -1, -1};
int cc[] = {1, 1, 0, -1, -1, -1, 0, 1};

const int mod = 1e9 + 7;
const int N = 300050;

signed main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    tarzan;
    int test = 1;
    //cin >> test;
    while(test--) {
        int n, m;
        cin >> n >> m;

        string s[n];
        for(int i = 0; i < n; i++) {
            cin >> s[i];
        }
        int dp[n][m];
        memset(dp, 0, sizeof dp);
        for(int i = 0; i < n; i++) {
            if(s[i][0] != '#') {
                dp[i][0] = 1;
            }
            else break;
        }
        for(int i = 0; i < m; i++) {
            if(s[0][i] != '#') {
                dp[0][i] = 1;
            }
            else break;
        }
        for(int i = 1; i < n; i++) {
            for(int j = 1; j < m; j++) {
                if(s[i][j] == '#') continue;
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod ;
            }
        }
        cout << dp[n - 1][m - 1];
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

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


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  /*
400 以上 599 以下：8
級
600
以上 799 以下：7
級
800
以上 999 以下：6
級
1000
以上 1199 以下：5
級
1200
以上 1399 以下：4
級
1400
以上 1599 以下：3
級
1600
以上 1799 以下：2
級
1800
以上 1999 以下：1 級
  */

  ll N; cin >> N;
 
  
  ll ans = (1999-N)/200 + 1;
  cout << ans << endl;
  }


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef vector<ll> vl;
typedef vector<vl> vv;
#define pb push_back
#define MOD 1000000007
#define INF 1000000000
#define endl '\n'
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }

int main(){
    
    fast();
    //#ifndef ONLINE_JUDGE
	//freopen("F:\\Codes\\input.txt", "r", stdin);
	//freopen("F:\\Codes\\output.txt", "w", stdout);
	//#endif
	
	ll n,i;
	cin>>n;

	vl hgt(n),dp(n+2,INT_MAX);

	for(i=0;i<n;i++){cin>>hgt[i];}
	dp[0]=0;
	for(i=0;i<n;i++){
		dp[i+1]=min(dp[i+1],dp[i]+abs(hgt[i]-hgt[i+1]));
		dp[i+2]=min(dp[i+2],dp[i]+abs(hgt[i]-hgt[i+2]));
	}
	cout<<dp[n-1]<<endl;

    
	return 0;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pld pair<long double, int>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define ff first
#define ss second
#define SZ(x) ((int)(x).size())
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    ll ans = 0, h = 0;
    for(int i = 0; i < N; i++){
        int x; cin >> x;
        if(x > h){
            h = x;
        }
        ans += (h - x);
    }
    cout << ans;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
vector<ll>vi,vs;
vector<ll> :: iterator vt;
ll arr[200009];
int main()
{
    ll n,t,x,y,z,j,i,k,flag =0,maxi=LONG_LONG_MIN ,mini=LONG_LONG_MAX,sum=0,c=0;
    map<ll,ll>mp;
    map<ll,ll> :: iterator mt;
    string s, ss;
    cin>>n;
    for(i = 0;i<n ;i++)
    {
        cin>>x;
        vi.push_back(x);
        vs.push_back(x);
    }
    sort(vi.begin(),vi.end());
    x= vi[n/2];
    y= vi[(n-2)/2];
    for(i = 0 ;i<n ;i++)
    {
        if(vs[i]<=y)
            cout<<x<<endl;
        else
            cout<<y<<endl;
    }
}


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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    
    bool A_turn = true;
    if (A % 2 == 1) A--;
    if (A % 2 == 1) B--;
    for(int i = 0; i < K; i++)
    {
        if (A_turn) {
            B += A / 2;
            A /= 2;
            A_turn = false;
        } else {
            A += B / 2;
            B /= 2;
            A_turn = true;
        }
    }
    
    cout << A  << " " << B << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int x,a;
  cin >> x >> a;
  if(x < a) cout << 0;
  else cout << 10;
}


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

const int geta = 20000;
bitset<40001> dp[80][80];

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

    int h, w; cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            int b; cin >> b;
            a[i][j] -= b;
            if (a[i][j] < 0) a[i][j] *= -1;
        }
    }

    dp[0][0][geta + a[0][0]] = dp[0][0][geta - a[0][0]] = true;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i < h - 1) dp[i + 1][j] |= dp[i][j] << a[i + 1][j] | dp[i][j] >> a[i + 1][j];
            if (j < w - 1) dp[i][j + 1] |= dp[i][j] << a[i][j + 1] | dp[i][j] >> a[i][j + 1];
        }
    }

    for (int i = 0; ; i++) {
        if (dp[h - 1][w - 1][geta + i] || dp[h - 1][w - 1][geta - i]) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}


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

int main(){
    int N;
    cin >> N;
    int p[N];
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    int count = 0;
    for(int i=0;i<N;i++){
        if((i+1)!=p[i]){
            count++;
        }
    }
    if(count==2||count==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#! /usr/bin/python
# -*- encoding: utf-8 -*-

import sys

if __name__ == '__main__':
    input = list(map(int, input().split()))
    inputA = input[0]
    inputB = input[1]
    
    if inputA < 0:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()
    
    if inputB < 0:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()

    if inputA == inputB:
        sys.stdout.write("IMPOSSIBLE")
        sys.exit()

    if (inputA + inputB) % 2 == 0:
        sys.stdout.write(str(int((inputA + inputB) / 2)))
        sys.exit()
      
    sys.stdout.write("IMPOSSIBLE")
    sys.exit()






Measured memory_bytes: 3064
import java.io.*;
import java.math.*;
import java.util.*;
import java.util.regex.*;


public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static long cnt=0;
	public static PrintWriter pw = new PrintWriter(System.out);
	public static void main(String[] args) throws Exception {
//		solveA(args);
//		solveB(args);
		solveC(args);
//		solveD(args);
//		solveE(args);
		if(in!=null){
			in.close();
		}
		pw.flush();
		pw.close();
	}

	public static void solveA(String[] args) throws Exception{
		String a = nextString();
		if('a'<= a.charAt(0) && a.charAt(0) <='z') {
			pw.println("a");

		}else {
			pw.println("A");
		}
	}
	public static void solveB(String[] args) throws Exception{
		int N=nextInt();
		int K=nextInt();

		int[] p = nextInts();
		Arrays.sort(p);
		int ans = 0;
		for(int i=0;i<K;i++) {
			ans+=p[i];
		}
		pw.println(ans);
	}
	public static void solveC(String[] args) throws Exception{
		long n = nextLong();
		String ans = "";
		while((n-1)/26!=0) {
			ans=(char)('a'+(n-1)%26)+ans;
			n=(n-1)/26;
		}
		ans=(char)('a'+(n-1)%26)+ans;
		pw.println(ans);
	}
	public static void solveD(String[] args) throws Exception{

	}
	public static void solveE(String[] args) throws Exception{

	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}

}



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

int main(void) {
	int n,i;
	scanf ("%d",&n);
	char st[100][11];
	for (i=0;i<n;i++) {
		scanf("%s",st[i]);
	}
	for (int i = 0; i < n; i++) {
		for (int j = i+1; j < n; j++) {
			if (strcmp(st[i], st[j]) == 0) {
				printf("No\n");
				return 0;
			}
		}
	}
	for (int i = 1; i < n; i++) {
		if (st[i-1][strlen(st[i-1])-1] != st[i][0]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int a[200][200];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    int h, w, n;
    cin >> h >> w >> n;
    int dy = 1;
    int x = 1;
    int y = 1;
    for (int i = 1; i <= n; i++){
        int k;
        cin >> k;
        while(k--){
            a[x][y] = i;
            y += dy;
            if (y == 0 || y == w + 1){
                if (y == 0){
                    y = 1;
                } else{
                    y = w;
                }
                x++;
                dy = -dy;
            }
        }
    }
    for (int i = 1; i <= h; i++, cout << endl){
        for (int j = 1; j <= w; j++){
            cout << a[i][j] << " ";
        }
    }
}


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

int main(){
  string s;
  cin >> s;
  
  int ans = 0;
  for(int i = 0; i < 3; i++){
    if(s[i] == '1') ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include "stdio.h"
using namespace std;

const int INF = 10000000;

struct Edge{
    Edge(int t, int c)
        : to(t), cost(c) {}

    int to;
    int cost;
};

bool visited[100];
typedef pair<int, int> PII;
vector<Edge> G[100];

int prim(int start){
    int ans = 0;
    fill(visited, visited+100, false);

    priority_queue<PII, vector<PII>, greater<PII> > que;

    que.push(PII(0, start));
    while (!que.empty()){
        PII p = que.top();
        int v = p.second;
        int cst = p.first;
        que.pop();
        if (visited[v]) continue;
        visited[v] = true;
        ans += cst;
        for (int i = 0; i < G[v].size(); i++){
            Edge e = G[v][i];
            if (!visited[e.to]){
                que.push(PII(e.cost, e.to));
            }
        }
    }

    for (int i = 0; i < 100; i++){
        G[i].clear();
    }
    
    return ans;
} 

int main(int argc, char const *argv[]){
    int n, m;

    while (cin>>n, n){
        cin>>m;
        for (int i = 0; i < m; i++){
            int a, b, d;
            scanf("%d,%d,%d", &a, &b, &d);
            d = (d-100) / 100;
            G[a].push_back(Edge(b, d));
            G[b].push_back(Edge(a, d));
        }

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

    return 0;
}

Measured memory_bytes: 3240