akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <fstream>
using namespace std;
#define fname ""
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define inf 1000000000
#define INF 1000000000000000000ll
const int N = 50;
ll a[N];
int n;

int main() {
	cin >> n;

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

	ll ans = 0;

	while (1) {
		int id = 1;
		for (int i = 2; i <= n; ++ i){
			if (a[id] < a[i]) id = i;
		}
		if (a[id] < n) break;
		ll need = a[id] / n;
		a[id] %= n;
		ans += need;

		for (int i = 1; i <= n; ++ i) {
			if (i != id) a[i] += need;
		}
	}

	cout << ans;

    return 0;
}


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

int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	for(int i=0;i<s.length();i++){
		printf("%c",'A'+((s[i]-'A'+n)%26));
	}
}


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

// a^n mod p を繰り返し2乗法で求める関数
ll mod_pow(ll a, ll n, ll p) {
	if (n == 1) return a % p;
	if (n % 2 == 1){
		return (a * mod_pow(a, n-1, p)) % p;
	} 
	else {
		ll t = mod_pow(a, n / 2, p);
		return (t * t) % p;
	}
}

// (a / b) mod p を求める関数
ll mod_div(ll a,ll b,ll p) {
	return (a * mod_pow(b, p-2, p)) % p; 
}

// nCr mod p を求める関数
ll nCr(ll n,ll r,ll p) {
	ll ans = 1;
	for (ll i=n; i>=n-r+1;i--) {
		ans = (ans * i) % p;
	}
	for (ll i=r; i>=1; i--) {
		ans = (ans * mod_pow(i, p-2, p)) % p;
	}
	return ans;
}

int main() {
	ll n, a, b;
	ll p = 1e9 + 7;
	cin >> n >> a >> b;
	ll mod_n = (mod_pow(2, n, p) - 1) % p;
	ll mod_a = nCr(n, a, p);
	ll mod_b = nCr(n, b, p);
	ll ans = (2*p + mod_n - mod_a - mod_b) % p;
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll A[MAX_N], B[MAX_N], C[MAX_N];
ll S[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, N) cin >> B[i];
	rep(i, 0, N) cin >> C[i];
	sort(A, A + N);
	sort(B, B + N);
	sort(C, C + N);
	rep(i, 0, N) {
		int at = upper_bound(C, C + N, B[i]) - C;
		S[i] = N - at;
	}
	rer(i, N, 0) {
		S[i] += S[i + 1];
	}
	ll ans = 0;
	rep(i, 0, N) {
		int at = upper_bound(B, B + N, A[i]) - B;
		ans += S[at];
	}
	cout << ans << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 13312
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <ctime>

#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair < int, int >
#define ull unsigned long long
#define pll pair < ll, ll >
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define all(s) s.begin(), s.end()
#define sz(a) (int)a.size()
#define filename "infinite"
const int inf = (1ll << 30) - 1;
const int N = (int)2e5 + 5;
using namespace std;


int n, a[105], m, M, cnt[105];

void endBad() {
	puts("Impossible");
	exit(0);
}

void solve() {
	scanf("%d", &n);
	m = inf;
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
		cnt[a[i]]++;
		m = min(a[i], m);
		M = max(a[i], M);
	}
	if (cnt[m] > 2) endBad();
	if (cnt[m] == 1) {
		if (M != m + m) endBad();
	} else {
		if (M != m + m - 1) endBad();
	}
	for (int i = m + 1; i <= M; i++)
		if (cnt[i] < 2) endBad();
	puts("Possible");
}

int main () {

	solve();


    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mdsaqib std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
#define all(c) (c).begin(),(c).end()
#define endl '\n'
using namespace std;

signed main(){
    mdsaqib;
    int s,t,d;
    cin >> d >> t>> s;
    if(d>s*t)cout << "No\n";
    else cout << "Yes\n";
    
}

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

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

using namespace std;

long long solve(int n,const string &s,int k){
	vector<long long> dp1(n+1); // dp1[i+1] := # of D in s(i-k,i]
	vector<long long> dp2(n+1); // dp2[i+1] := # of M in s(i-k,i]
	vector<long long> dp3(n+1); // dp3[i+1] := # of subseq DM in s(i-k,i]

	rep(i,n){
		dp1[i+1]=dp1[i];
		dp2[i+1]=dp2[i];
		if(i-k>=0 && s[i-k]=='D') dp1[i+1]--;
		if(i-k>=0 && s[i-k]=='M') dp2[i+1]--;
		if(s[i]=='D') dp1[i+1]++;
		if(s[i]=='M') dp2[i+1]++;
	}

	rep(i,n){
		dp3[i+1]=dp3[i];
		if(i-k>=0 && s[i-k]=='D') dp3[i+1]-=dp2[i];
		if(s[i]=='M') dp3[i+1]+=dp1[i+1];
	}

	long long res=0;
	rep(i,n) if(s[i]=='C') res+=dp3[i+1];
	return res;
}

int main(){
	int n,q,k;
	string s; cin>>n>>s>>q;

	rep(i,q) cin>>k, cout<<solve(n,s,k)<<endl;

	return 0;
}


Measured memory_bytes: 26776
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N;
    cin >> N;
    int A[N];
    int cnt = 0;
    rep(i, N){
        cin >> A[i];
        if(A[i] % 2 == 0){
            cnt++;
        }
    }
    int ans = pow(3, N) - pow(2, cnt);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cctype>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define SZ(a) ((int)((a).size()))
#define REPSZ(i,v) REP(i,SZ(v))
#define ALL(a) (a).begin(),(a).end()
typedef long long Int;

template<class T> void pv(T a, T b){for(T i=a;i!=b;++i)cout<<*i<<' ';cout<<endl;}

int dp[1000 * 1000 + 10];
int dp_odd[1000 * 1000 + 10];

int main() {
  int v[200];
  for(int i = 0; i < 200; i++) {
    v[i] = i * (i + 1) * (i + 2) / 6;
  }

  memset( dp, -1, sizeof(dp) );
  memset( dp_odd, -1, sizeof(dp_odd) );

  dp[0] = dp_odd[0] = 0;

  for(int i = 0; i < 200; i++)
    for(int j = 0; j + v[i] <= 1000 * 1000; j++) {
      if( dp[j] != -1 ) {
        if( dp[j + v[i]] == -1 || dp[j + v[i]] > dp[j] + 1 )
          dp[j + v[i]] = dp[j] + 1;
      }

      if( (v[i] & 1) && dp_odd[j] != -1 ) {
        if( dp_odd[j + v[i]] == -1 || dp_odd[j + v[i]] > dp_odd[j] + 1 )
          dp_odd[j + v[i]] = dp_odd[j] + 1;
      }

    }

  for(int N; cin >> N, N; ) {
    cout << dp[N] << " " << dp_odd[N] << endl;
  }
  return 0;
}

Measured memory_bytes: 8564
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int count[27]={0};
	int flag=0;
	for(int i=0;i<s.length();i++){
		count[s[i]-'a'+1]++;
	}
	for(int i=0;i<27;i++){
		if(count[i]>1){
			flag=1;
			break;
		}
	}
	if(!flag) cout<<"yes"<<endl;
	else cout<<"no"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
using namespace std;

int a[1010][1010];
int dr[4]={-1, 0, 1, 0};
int dc[4]={0, -1, 0, 1};
int main()
{
    int n, m; cin>>n>>m;
    queue<pair<int, int>> q;
    for(int i=0; i<n; ++i) {
        string s; cin>>s;
        for(int j=0; j<m; ++j) if (s[j]=='#') {
            q.emplace(i, j);
            a[i][j]=1;
        }
    }

    int res=0;
    while (!q.empty()) {
        auto p=q.front(); q.pop();
        int r=p.first, c=p.second;
        res=max(res, a[r][c]-1);
        for(int i=0; i<4; ++i) {
            int nr=r+dr[i], nc=c+dc[i];
            if (nr<0 or nr>=n or nc<0 or nc>=m) continue;
            if (a[nr][nc]) continue;
            q.emplace(nr, nc);
            a[nr][nc]=a[r][c]+1;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 12432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	ll s;cin>>s;
	ll a,b;
	a=(inf-s%inf)%inf;
	b=(s+a)/(ll)(inf);

	cout<<"0 0 "<<inf<<" 1 "<<a<<" "<<b<<"\n";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
            int a = stdIn.nextInt();
            int b = stdIn.nextInt();
            int c = stdIn.nextInt();

            if(a>b){
                int temp = a;
                a = b;
                b = temp;
            }
            if(b>c){
                int temp = b;
                b = c;
                c = temp;
            }
            if(a>b){
                int temp = a;
                a = b;
                b = temp;
            }

            System.out.println(a +" "+ b +" "+ c);
            stdIn.close();
    }
}


Measured memory_bytes: 26192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

ll ans = 0;

void solve(ll p[], ll c[], int k, int i, int visited[]) {
	visited[i] = 1;
	vector<ll> arr;
	arr.pb(c[i]);
	while(true) {
		int idx = p[i];
		if(visited[idx]) break;
		arr.pb(c[idx]);
		visited[idx] = 1;
		i = idx;
	}
	ll n = arr.size();
//	f(i,n) cout<<arr[i]<<" ";
//	cout<<n<<" ";
	ll sum[n+1] = {0};
	sum[0] = 0;
	for(int j=1; j<=n; j++) {
		ll res = 0;
		for (int i=0; i<j; i++) res += arr[i];
       	ll curr = res;
       	for(int i=j; i<n+j; i++) {
       		curr += arr[i%n] - arr[(i-j)%n];
       		res = max(res,curr);
		}
		sum[j] = res;
	}
//	cout<<sum[4]<<" ";
	if(k < n) {
		ans = max(ans,*max_element(sum+1,sum+k+1));
	}
	else {
		ans = max(ans,*max_element(sum+1,sum+n+1));
		if(k%n == 0) {
			ans = max(ans,(*max_element(sum+1,sum+n+1)) + sum[n]*(k/n-1));
		}
		else
			ans = max(ans,sum[n]*(k/n) + *max_element(sum+1,sum+k%n+1));
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		ll n,k;
		cin>>n>>k;
		int visited[n+1] = {0};
		ll p[n+1], c[n+1];
		for(int i=1; i<=n; i++) cin>>p[i];
		for(int i=1; i<=n; i++) cin>>c[i];
		ll maxi = *max_element(c+1,c+n+1);
		if(maxi <= 0) {
			cout<<maxi<<"\n";
		}
		else {
			for(int i=1; i<=n; i++) {
				if(!visited[i]) {
					solve(p,c,k,i,visited);
				}
			}
			cout<<ans<<"\n";
		}
		
 	}
 	return 0;
}


Measured memory_bytes: 3848
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;

int A[100000];
map <int, int> counts;
map <int, int> can_use;
int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    for(int i = 0; i < N; i++){
        if(counts.find(A[i]) != counts.end()){
            counts[A[i]] ++;
        } else {
            counts[A[i]] = 1;
        }
    }

    int ans = counts.size();
    vector <int> more_than_one;
    int more_than_one_num = 0;
    vector <int> one;
    for(auto it = counts.begin(); it != counts.end(); it++){
        if(it->second > 1){
            more_than_one.push_back(it->first);
        } else {
            one.push_back(it->first);
        }
    }
    sort(more_than_one.begin(), more_than_one.end());
    sort(one.begin(), one.end());

    if((N - one.size() - more_than_one.size()) % 2 == 0){
        cout << ans << endl;
    } else {
        cout << ans - 1 << endl;
    }

    return 0;
}

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

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector<long long> v(N+1, 0);
  map<long long, long long> m;
  m[0]++;
  for (int i = 0; i < N; i++) {
    cin >> v[i+1];
    v[i+1] += v[i];
    m[v[i+1]]++;
  }
  long long res = 0;
  for (auto x : m) {
    res += x.second * (x.second - 1) / 2;
  }
  cout << res << endl;
}


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

int main()
{
  	
	int64_t n;
	int64_t d;
	cin >> n;
  	cin >> d;
  	int64_t d2 = d*d;
  
  	vector<int64_t> x(n);
  	vector<int64_t> y(n);
  
  	for(int i=0; i<n; ++i){
      	cin >> x[i];
      	cin >> y[i];
    }
  
  	int count = 0;
  	for(int i=0; i<n; ++i){
      int64_t dis = x[i] * x[i] + y[i] * y[i];
      if (d2 >= dis ){
        	count++;
      }
    }
  
  	cout << count;
  
    return 0;
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define mp make_pair
#define pii pair<int, int>
#define PB push_back
#define F first
#define S second
#define Task ""
using namespace std;
const int N=200005;
const long long inf=5e18;
long long dp[N][5];
int n, a[N];
#define cmin(x, y) (x=min(x, y))

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    cin >> n;
    rep(i, 1, n) cin >> a[i];
    rep(i, 1, n)
        rep(j, 0, 4) dp[i][j]=inf;

    rep(i, 1, n) {
        long long xx=dp[i-1][0];
        dp[i][0]=dp[i-1][0]+a[i];
        dp[i][1]=cmin(xx, dp[i-1][1])+(a[i]? ((a[i]&1)?1:0) : 2);
        dp[i][2]=cmin(xx, dp[i-1][2])+(a[i]? ((a[i]&1)?0:1) : 1);
        dp[i][3]=cmin(xx, dp[i-1][3])+(a[i]? ((a[i]&1)?1:0) : 2);
        dp[i][4]=cmin(xx, dp[i-1][4])+a[i];
    }
    long long ans=inf;
    rep(i, 0, 4) ans=min(ans, dp[n][i]);
    cout << ans;
    return 0;
}


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

int main() {
	
  int N;
  cin >> N;
  
  for(;;) {
  	if(N <= 1000) {
    	break;
    }
    N -= 1000;
  }
  
      

	cout << 1000 - N << endl;

}
  
  

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

void say(string s) {cout << s << endl;}

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

    int a, b;
    cin >> a >> b;
    if ((a <= 8) && (b <= 8)) cout << "Yay!" << endl;
    else cout << ":(" << endl;

    return 0;
}

Measured memory_bytes: 256
S = input()

ACGT = ['A','C','G','T']

num_list = [-1]
for i in range(len(S)):
  if S[i] not in ACGT:
    num_list.append(i)

num_list.append(len(S))

dif_list = []
for i in range(len(num_list)-1):
  dif_list.append(num_list[i+1]-num_list[i])
  
print(max(dif_list)-1)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException{
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int h = Integer.parseInt(str[0]);
    int a = Integer.parseInt(str[1]);
    int num = 0;    
    for(int i = 1; h>0; i++){
      h=h-a;
      num++;
    }
    System.out.println(num);
  }
}

Measured memory_bytes: 20948
#!/usr/bin/python3

import re
from pprint import pprint


n = input()
s = input()

sb = re.sub(r'^0+', '', s)
sb = re.sub(r'0+$', '', sb)
sb = re.sub(r'00+', '-', sb)
#pprint('---- sb = %s' % (sb, ))

tlist = sb.split('-')
#pprint('---- tlist = %s' % (tlist, ))

counts_list = []
for t in tlist:
    counts = []
    tt = t.split('0')
    for ttt in tt:
        counts.append(len(ttt))
    counts_list.append(counts)
#pprint('---- counts_list = %s' % (counts_list, ))

ans = 0

for counts in counts_list:

    len_counts = len(counts)
    sum_all = sum_decr = sum_one = sum_zero = 0

    for i in range(len_counts - 1):

        new_sum_all = new_sum_decr = new_sum_one = new_sum_zero = 0

        # do nothing
        new_sum_all = max(sum_all, sum_decr, sum_one, sum_zero)

        # go to left all
        new_sum_decr = max(new_sum_decr, sum_all + counts[i])
        new_sum_decr = max(new_sum_decr, sum_decr + counts[i] - 1)
        new_sum_decr = max(new_sum_decr, sum_one + 1)

        # go to right all - 1
        new_sum_one = max(new_sum_one, sum_all + counts[i+1] - 1)
        if (counts[i] >= 2):
            new_sum_one = max(new_sum_one, sum_decr + counts[i+1] - 1)
        new_sum_one = max(new_sum_one, sum_one + counts[i+1] - 1)

        # go to right all
        new_sum_zero = max(new_sum_zero, sum_all + counts[i+1])
        if (counts[i] >= 2):
            new_sum_zero = max(new_sum_zero, sum_decr + counts[i+1])
        new_sum_zero = max(new_sum_zero, sum_one + counts[i+1])

        sum_all = new_sum_all
        sum_decr = new_sum_decr
        sum_one = new_sum_one
        sum_zero = new_sum_zero

        #pprint('  sum_all=%d sum_decr=%d sum_one=%d sum_zero=%d' %
        #       (sum_all, sum_decr, sum_one, sum_zero))

    #pprint('---- incr = %d' % max(sum_all, sum_decr, sum_one, sum_zero))

    ans += max(sum_all, sum_decr, sum_one, sum_zero)


print(ans)


Measured memory_bytes: 16292
#include <stdio.h>

int main(void){
	int a,c,n,t;
	while(1){
		c=0;
		scanf("%d",&n);
		if(n==0){
			return 0;
		}
		for(t=0;t<n*(n-1)/2;t++){
			scanf("%d",&a);
			c+=a;
		}
		printf("%d\n",c/(n-1));
	}
	return 0;
}

Measured memory_bytes: 600
#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>;

ll x = 1e9 + 7; 
const int INF = 1001001001;

bool f(string s) {
  string sr = s;
  reverse(sr.begin(), sr.end());
  if (sr == s) return true;
  else return false;
}

int main() {
  double l;
  cin >> l;
  printf("%.12f\n", l*l*l/27);
  return 0;
}

Measured memory_bytes: 3716
#include<iostream>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;

	if (a < b) {
		cout << "a < b" << endl;
	}

	if (a > b) {
		cout << "a > b" << endl;
	}

	if (a == b) {
		cout << "a == b" << endl;
	}

}


Measured memory_bytes: 3076
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

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

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

    int x = 0;
    int max_x = 0;;
    for(int i = 0; i < S.size(); i++)
    {
        if (S[i] == 'I')
        {
            x++;
            if (max_x < x)
            {
                max_x = x;
            }
        }
        else if (S[i] == 'D')
        {
            x--;
        }
        
    }

    cout << max_x << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=55;

ll n=50,k,a[N];
ll times,rest;

int main(){
	scanf("%lld",&k);
	times=k/n,rest=k%n;
	rep(i,1,n) a[i]=n-1+times;
	rep(i,1,rest){
		a[i]+=n;
		rep(j,1,n) if(j!=i) --a[j];
	}
	printf("%lld\n",n);
	rep(i,1,n) printf("%lld ",a[i]);
	puts("");
	return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<long long>> a(n, vector<long long>(2));
  for (int i = 0; i < n; i++) cin >> a.at(i).at(0) >> a.at(i).at(1);
  sort(a.begin(), a.end());
  long long money = 0, num = 0;
  for (int i = 0; i < n; i++) {
    if (num + a.at(i).at(1) <= m){
      num += a.at(i).at(1);
      money += a.at(i).at(0) * a.at(i).at(1);
    }
    else {
      cout << money + a.at(i).at(0) * (m - num) << endl;
      return 0;
    }
  }
  cout << money << endl;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
using namespace std;
const int nmax = 8;
bool graph[nmax][nmax];
int dfs(int v, int N, bool visited[nmax]) {
	bool all_visited = true;
	for (int i = 0; i < N; i++) {
		if (visited[i] == false) all_visited = false;
	}
	if (all_visited) return 1;
	int ret = 0;
	for (int i = 0; i < N; i++) {
		if (graph[v][i] == false) continue;
		if (visited[i]) continue;

		visited[i] = true;
		ret += dfs(i, N, visited);
		visited[i] = false;
	}
	return ret;
}
int main(void) {
	int N, M; cin >> N >> M;
	for (int i = 0; i < nmax; i++) {
		for (int j = 0; j < nmax; j++) {
			graph[i][j] = false;
		}
	}
	for (int i = 0; i < M; i++) {
		int A, B; cin >> A >> B;
		graph[A - 1][B - 1] = graph[B - 1][A - 1] = true;
	}
	bool visited[N];
	for (int i = 0; i < N; i++) visited[i] = false;
	visited[0] = true;
	cout << dfs(0, N, visited) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{	
	int a,b;
	while(cin>>a>>b)
	{
		if(a==0&&b==0)break;
		for(int i=0;i<a;i++)
		{
			for(int j=0;j<b;j++)
			{
				cout<<"#";
			}
			cout<<endl;
		}
		cout<<endl;
	}
	return 0;	
}


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

int main() {
	
	double a,b;
	cin >> a >> b;
	
	for(double i = 1; i <= 2000; i++){
		int x = i * 0.08;
		int y = i * 0.1;
		
		if (x == a && y == b){
			cout << i << endl;
			return 0;
		}
	}
	
	cout << -1 << endl;
	return 0;
}






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

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

const int mod = 1000000007;
const int inf = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> ans(n);
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int x = 1; x * x < n; x++) {
      for (int y = x; y * y < n; y++) {
        int t = 4 * i - 3 * x * x - 2 * x * y - 3 * y * y;
        int c = x + y;
        if (t < 0) continue;
        if (sqrt(t) - c <= 0) continue;
        double z = ((double)sqrt(t) - (double)c) / 2;
        if ((int)z < y) continue;
        // cout << x << ' ' << y << ' ' << z << endl;
        if (z - floor(z) == 0.0f) {
          // printf("%d,%d,%lf,%d\n", x, y, z, i);
          if (x == y && y == z) {
            cnt++;
          } else if (x == y || y == z || z == y) {
            cnt += 3;
          } else {
            cnt += 6;
          }
        }
      }
    }
    ans[i - 1] = cnt;
  }
  rep(i, n) cout << ans[i] << endl;
}


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

int main()
{
	int i,j;
	
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
			cout << i << "x" << j << "=" << i*j <<  "\n";
		}
	}
	
	return 0;
	
}

Measured memory_bytes: 1112
#include <stdio.h>

int main()
{
    int b1[3][10], b2[3][10], b3[3][10], b4[3][10], n, b, f, r, v;

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            b1[i][j] = 0;
            b2[i][j] = 0;
            b3[i][j] = 0;
            b4[i][j] = 0;
        }
    }
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d %d %d %d", &b, &f, &r, &v);

        if (b == 1)
            b1[f - 1][r - 1] += v;
        if (b == 2)
            b2[f - 1][r - 1] += v;
        if (b == 3)
            b3[f - 1][r - 1] += v;
        if (b == 4)
            b4[f - 1][r - 1] += v;
    }
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            printf(" %d", b1[i][j]);
        }
        puts("");
    }
    puts("####################");
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            printf(" %d", b2[i][j]);
        }
        puts("");
    }
    puts("####################");
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            printf(" %d", b3[i][j]);
        }
        puts("");
    }
    puts("####################");
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            printf(" %d", b4[i][j]);
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 2692
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
using namespace std;

const int INF = 1087654321;

int main(void)
{
	for (;;)
	{
		int n, m;
		cin >> n >> m;
		if (!n)break;
		vector<int>c;
		for (int i = 0; i < m; ++i)
		{
			int cc; cin >> cc;
			c.push_back(cc);
		}
		array<int, 256>dp;
		fill(dp.begin(), dp.end(), INF);
		dp[128] = 0;
		for (int i = 1; i <= n; ++i)
		{
			array<int, 256>ndp;
			fill(ndp.begin(), ndp.end(), INF);
			int x;
			cin >> x;
			for (int val = 0; val < 256; ++val)
			{
				/*
				if (val == 0)
				{
					int gap = -1;
					for (int ck : c)gap = max(gap, -ck);
					for (int old = 0; old <= gap; ++old)
					{
						ndp[val] = min(ndp[val], dp[old]);
					}
				}
				else if (val == 255)
				{
					int gap = -1;
					for (int ck : c)gap = max(gap, ck);
					for (int old = 255 - gap; old < 256; ++old)
					{
						ndp[val] = min(ndp[val], dp[old]);
					}
				}
				//*/
				for (int ck : c)
				{
					/*
					int old = val - ck;
					if (old < 0)old = 0;
					if (old >= 256)old = 255;
					ndp[val] = min(ndp[val], dp[old]);
					//*/
					ndp[min(255, max(val + ck, 0))] = min(ndp[min(255, max(val + ck, 0))], dp[val]);
				}
			}
			for (int i = 0; i < 256; ++i)
			{
				dp[i] = ndp[i] + (x - i) * (x - i);
			}
		}
		int ans = INF;
		for (int can : dp)
		{
			ans = min(ans, can);
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main()
{
	int h, w, n; cin >> h >> w >> n;
	
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];		
	
	vector<int> st(h * w);
	vector<vector<int>> ans(h, vector<int>(w));

	int cnt = 1;
	int k = 0;
	int hw = h * w;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < a[i]; j++) {
			st[k] = cnt;
			k++;
		}
		cnt++;
	}

	cnt = 0;

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			ans[i][j] = st[cnt];
			cnt++;
		}
	}

	for (int i = 0; i < h; i++) {
		if (i % 2 != 0 ) {
			reverse(ans[i].begin(), ans[i].end());
		}
	}
	
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << ans[i][j] << " ";
		}
		cout << endl;
	}

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll n,g=0,f=0,k,l,c=0,x,t=0;
    double r = 3.14159265358979323846,m;
    cin>>n;
    m = 2*r*n;
    cout<<m<<endl;

}


Measured memory_bytes: 3744
#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++)


int main() {
  int n,a,b;
  cin >> n>>a>>b;
  string s;
  cin>>s;
  vector<bool>ans(n);
  int ca=0;
  int cb=0;
  rep(i,n){
    
    
      if(ca<a+b&&s.at(i)=='a'){
        ans.at(i)=true;
        ca++;
      }
      if(cb<b&&ca<a+b&&s.at(i)=='b'){
        ans.at(i)=true;
        cb++;
        ca++;
      }
    
  }
  rep(i,n){
    if(ans.at(i)){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}

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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int maxnum = max(a, max(b, c));
    int minnum = min(a, min(b, c));
    if (maxnum == 7 && a + b + c - maxnum - minnum == 5) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String st = sc.next();
		boolean ok = true;
		if (st.charAt(0)!='A') ok = false;
		int count=0;
		for (int i=2;i<st.length()-1;i++)
			if (st.charAt(i)=='C') count++;
		if (count!=1) {
			ok = false;
		}
		
		for (int i=1;i<st.length();i++)
			if (st.charAt(i)!='C' && st.charAt(i)!=st.toLowerCase().charAt(i)) {
				ok = false;
			}
		
		if (ok) System.out.println("AC");
		else System.out.println("WA");

	}
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll dep(ll a,ll b){
	if(b==0){
		return a;
	}
	dep(b,a%b);
	return a;
}
ll gcd (unsigned int n1, unsigned int n2) {
    return (n2 == 0) ? n1 : gcd (n2, n1 % n2);
}
int main() {
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++){
			for(ll k=1;k<=n;k++){
				//cout << "k";
				ll now=gcd(max(k,j),min(k,j));
			//	cout << "k";
				ans+=gcd(max(now,i),min(now,i));
			}
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll K,X;
    cin >> K >> X;

    ll basho = X,i = 0;;

    while(i < K){
        cout << X - K + i + 1<< endl;
        i++;
    }

    for(i = 1;i < K;i++){
        cout << X + i << endl;
    }

}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    string t;
    cin >> t;
    int len = (int)t.size();
    ll res = 0;
    ll cur = 0;
    vector<bool> in(len, false);
    for (int i=0; i<len; ++i) {
        if (t.at(i) == '1') {
            in.at(i) = true;
            ++cur;
            res += (cur+1) / 2;
        }
    }
    ll used = 0;
    ll fowZero = 0, fowOne = 0;
    for (int i=0; i<len; ++i) {
        if (t.at(i) == '0') {
            if (used%2 == 1) {
                in.at(i) = true;
                ++cur;
                res += (cur+1) / 2;
                ++fowZero;
                ++used;
            }
        } else {
            ++used;
            ++fowOne;
        }
    }
    ll backOdd = 0, backEven = 0;
    for (int i=len-1; i>=0; --i) {
        if (t.at(i) == '0') {
            if (in.at(i)) {
                ++backEven;
                --fowZero;
            } else {
                in.at(i) = true;
                if ((fowOne + fowZero) % 2 == 0) ++backEven;
                else ++backOdd;
                swap(backOdd, backEven);
                ++cur;
                res += (cur+1) / 2 - backOdd;
            }
        } else {
            --fowOne;
        }
    }
    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3788
N=int(input())
A=[0]*N
L=[[[-1]*2 for i in range (15)] for j in range (N)]
C=[1]*N
c=2**N-1
H=0
for i in range(N):
    A[i]=int(input())
    for j in range(A[i]):
        L[i][j][0],L[i][j][1]=map(int,input().split())

for i in range(c,-1,-1):
    C=list(format(i, '015b'))
    f=0
    M=C[15-N:15]
    h=0
    for e in range(N):
        h+=int(M[e])
    if(H>=h):break
    for k in range(N):
        for l in range(15):
            if(int(M[k])==0):break
            if(L[k][l][0]==-1):break
            if((int(M[L[k][l][0]-1])) != int(L[k][l][1])):
                f=1
                break
        if(f==1):
            break
    if(f==0):
        H=h

print(H)



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

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

    li n, k;
    cin >> n >> k;
    vector<li> as(n);
    for (int i = 0; i < n; ++i) {
        cin >> as[i];
    }

    for (int j = 0; j < min(k, 50LL); ++j) {
        vector<li> upds(n + 1);
        for (int p = 0; p < n; ++p) {
            upds[max(p - as[p], 0LL)] += 1;
            upds[min(p + as[p] + 1, n)] -= 1;
        }
        for (int i = 0; i < n; ++i) {
            upds[i + 1] += upds[i];
            as[i] = upds[i];
        }

    }


    for (int i = 0; i < n; ++i) {
        cout << as[i];
        if (i + 1 == n) {
            cout << endl;
        } else {
            cout << ' ';
        }
    }

    return 0;
}

Measured memory_bytes: 6336
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

typedef long long lint;

using namespace std;

int main()
{

	string S;
	cin >> S;

	int N = S.size();
	vector<int> q;
	// S: (0 or 1) * N
	bool haspre = false;
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		haspre = (q.size() > 0) ? true : false;
		if (haspre && (S[i] != q.back()))
		{
			ans += 2;
			q.pop_back();
		}
		else
		{
			q.push_back(S[i]);
		}
/*
		for (auto kk : q) {
			cout << kk;
		}
		cout << endl;
*/
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1020
X,Y=map(int,input().split())
mod=10**9+7


def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル


if (Y>2*X) or (Y < X/2) or ((X+Y)%3)!=0:
    ans=0
else:
    n=((X+Y)//3)
    r=min((abs(X-(X+Y)//3)),abs(Y-(X+Y)//3))
    for i in range(2, N + 1):
        g1.append((g1[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod // i)) % mod)
        g2.append((g2[-1] * inverse[-1]) % mod)
    ans= cmb(n, r, mod)

print(ans)

Measured memory_bytes: 127696
#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, n) for (int i = (n)-1; i >= 0; --i)
#define rrep2(i, a, b) for (int i = (a)-1; i >= (int)b; --i)
#define range(i, a, b, c) for (int i = a;             \
                                   c > 0 ? i < b : i > b; \
                                   i += c)
#define chmax(a, b) (a = (a) < (b) ? (b) : (a))
#define chmin(a, b) (a = (a) > (b) ? (b) : (a))
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) begin(a), end(a)
#define ifnot(a) if (not(a))
#define int long long

#ifdef LOCAL_ENV

#if TEST_MODE == true
const bool test = true;
#define dump(x) cerr << #x << " = " << (x)
#define dumpl(x) dump(x) << endl
#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

#else
const bool test = false;
#define dump(x) 
#define dumpl(x)
#endif

int dx[] = { 1, 0, -1, 0 };
int dy[] = { 0, 1, 0, -1 };
const int INF = (int)1 << 60;
const ll INFL = (ll)1 << 60;
ll mod_n = (int)1e9 + 7;
const double eps = 1e-10;
typedef long double Real;
// return -1, 0, 1
int sgn(const Real &r) { return (r > eps) - (r < -eps); }
int sgn(const Real &a, const Real &b) { return sgn(a - b); }

//.....................
const int MAX = (int)2e5 + 5;

vector<string> split(const string &str, char sep)
{
	vector<string> v;
	stringstream ss(str);
	string buffer;
	while (getline(ss, buffer, sep))
	{
		v.push_back(buffer);
	}
	return v;
}

template <class InputIterator>
int sum(InputIterator begin, InputIterator end)
{
	return accumulate(begin, end, 0ll);
}

template<typename T>
T gcd(T a, T b)
{
	T c;
	while (a != 0) {
		c = a; a = b%a;  b = c;
	}
	return b;
}

class Solver {
public:
	int N;

	int S(int N) {
		auto s = to_string(N);
		rep(i, s.size()) s[i] -= '0';
		return sum(all(s));
	}

	void solve() {
		cin >> N;
		puts(N % S(N) == 0 ? "Yes" : "No");
	}
};

signed main()
{
	srand((unsigned int)time(NULL));
	cout << fixed << setprecision(20);
	auto ptr = new Solver();
	ptr->solve();
	delete ptr;
	//while (true) {
	//	if (cin.eof() == true) break;
	//	auto ptr = new Solver();
	//	ptr->solve();
	//	delete ptr;
	//}
	return 0;
}

// class Mycin {
// 	bool flag = true;
// public:
// 	Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;}
// 	Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;}
// 	Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;}
// 	operator bool() {return flag;}
// } mycin;

// class Mycout {
// public:
// 	Mycout& operator << (const int& a) {printf("%lld", a); return *this;}
// 	Mycout& operator << (const char c) {printf("%c", c); return *this;}
// 	Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;}
// } mycout;

// #define cin mycin
// #define cout mycout
// #define endl '\n'

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

#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#define ll              long long int
#define ull             unsigned long long
#define vi              vector<int>
#define vl              vector<ll>
#define vvi             vector<vector<int> >
#define pi              pair<int,int>
#define vii             vector<pi>

#define sz(v)           ((int)(v).size())
#define all(s)          s.begin(),s.end()
#define allr(s)         s.rbegin(),s.rend()
#define unq(c)          (sort(all(c)), c.resize(distance(c.begin(),unique(all(c)))))
#define get_pos(c,x)    (lower_bound(all(c),x)-c.begin())

#define MS0(v)          memset((v), 0, sizeof((v)))
#define MS1(v)          memset((v), -1, sizeof((v)))
#define LEN(v)          strlen(v)

#define MP              make_pair
#define pb              push_back
#define pob             pop_back
#define ff              first
#define ss              second
#define sc              scanf
#define pf              printf
#define endl            "\n"

#define TEST_CASE       int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define PRINT_CASE      printf("Case %d: ",cs)

#define vpf(v)          for(int i=0;i<v.size();i++){cout<<v[i];if(i!=v.size()-1)cout<<" ";else cout<<"\n";}
#define vsc(v)          for(int i=0;i<v.size();i++)cin>>v[i];

#define REP(i, n)       for (int i = 0; i < (n); i++)
#define REPP(i, a, b)   for (int i = (a); i < (b); i++)
#define FOR(i, a, b)    for (int i = (a); i <= (b); i++)
#define FORS(i, s)      for (int i = 0; s[i]; i++)

#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fileio          freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)

#define intlim          2147483648
#define infinity        (1LL<<50)

#define gcd(a, b)       __gcd(a, b)
#define lcm(a, b)       ((a)*((b)/gcd(a,b)))


int on_bit(int N,int pos){return N = N | (1<<pos);}
int off_bit(int N,int pos){return N = N & ~(1<<pos);}
bool check_bit(ll N,int pos){return (bool)(N & (1<<pos));}


#define start_clock     clock_t tStart = clock()
#define end_clock       printf("\n>>Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC)



//____________________________________________________________________________________________________________




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

    int x = n/500;
    n = n%500;

    cout<< (x*1000) + ((n/5)*5) <<"\n";
    return 0;
}

Measured memory_bytes: 256
<?php

while($line = fgets(STDIN)){
	list($p, $q) = explode(" ", trim($line));
	
	$shou = array();
	$amari = array();
	while(true){
		$amari[] = $p;
		
		$p *= 10;
		$s = intval($p/$q);
		$r = $p % $q;
		$shou[] = $s;
		
		if($r == 0){
			// ???????????????
			echo implode("", $shou)."\n";
			break;
		}
		
		$i = array_search($r, $amari);
		if($i !== false){
			// ?????°??????
			echo implode("", $shou)."\n";
			echo str_repeat(" ", $i);
			echo str_repeat("^", count($amari) - $i)."\n";
			break;
		}
		
		$p = $r;
	}
}

Measured memory_bytes: 15404
H, W = map(int, input().split())
a = []
for i in range(H):
    a.append(input())
row = [False]*H
col = [False]*W
for i in range(H):
    for j in range(W):
        if a[i][j] == "#":
            row[i] = True
            col[j] = True
for i in range(H):
    if row[i]:
        for j in range(W):
            if col[j]:
                print(a[i][j], end = "")
        print("", end = "\n")


Measured memory_bytes: 4468
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


def main():
    S = input()
    ans = 0

    for n in range(2**(len(S)-1)):
        B = to_bin(n)

        B = "0" * (len(S) - len(B) - 1) + B

        expr = S[0]
        for b,s in zip(B, S[1:]):
            if b == "1":
                expr += "+"
            expr += s


        ans += eval(expr)

    print(ans)


main()


Measured memory_bytes: 4748
a = int(input())

N = [1,2,3,4,5,6,7,8,9]

for x in range(a):
  tmp = N[x]
  if tmp%10 != 0:
    N.append(tmp*10+tmp%10-1)
  N.append(tmp*10+tmp%10)
  if tmp%10 != 9:
    N.append(tmp*10+tmp%10+1)
print(N[a-1])

Measured memory_bytes: 15784