akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define pf push_front
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define rsz resize()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); } 
int bit(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bit(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#ifndef LOCAL
string to_string(__int128 x) {
	string s = "";
	bool neg = 0;
	if(x < 0) { s += "-"; neg = 1; }
	if(!x) s += '0';
	while(x) {
		int rem = x % 10;
		s += to_string(rem);
		x /= 10;
	}
	reverse(s.begin() + neg, s.end());
	return s;
}
#endif

const int mod = 1e9 + 7; // 998244353;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
*/

const int N =  205;
char a[N][N];

int c[N];
int n;

bool pos = 1;

void dfs(int u,int col) {
	c[u] = col;
	fr(i, 1, n) {
		if(a[u][i] == '1') {
			if(c[i] == -1) dfs(i, col ^ 1);
			else if(c[i] != (col ^ 1)) pos = 0;
		}
	}
}

void solve() {
	memset(c, -1, sizeof c);
	cin >> n;
	fr(i, 1, n) {
		fr(j, 1, n) {
			cin >> a[i][j];
		}
	}
	dfs(1, 0);
	if(!pos) {
		cout << -1 << endl;
		return;
	}
	int ans = 0;
	fr(i, 1, n) {
		vector<int> dist(n + 1, 1e9);
		queue<int> q;
		dist[i] = 1;
		q.push(i);
		while(!q.empty()) {
			int u = q.front();
			q.pop();
			ans = max(ans, dist[u]);
			fr(i, 1, n) {
				if(a[u][i] == '1' && dist[i] > dist[u] + 1) {
					dist[i] = dist[u] + 1;
					q.push(i);
				}
			}
		}
	}
	cout << ans << endl;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 384
import math  # noqa
import bisect  # noqa
import queue  # noqa


if __name__ == '__main__':
    H, W = map(int, input().split())
    S = [[s for s in input()] for _ in range(H)]

    INF = 1000000005
    traj = [[INF for _ in range(W)] for _ in range(H)]
    que = queue.Queue()
    que.put((0, 0))
    traj[0][0] = 0 if S[0][0] == '.' else 1
    while not que.empty():
        h, w = que.get()
        d = ((0, 1), (1, 0))
        for dh, dw in d:
            nh = h + dh
            nw = w + dw
            if nh < 0 or H <= nh or nw < 0 or W <= nw:
                continue
            cost = traj[h][w]
            if S[h][w] == '.' and S[nh][nw] == '#':
                cost += 1
            if cost < traj[nh][nw]:
                traj[nh][nw] = cost
                que.put((nh, nw))

    print(traj[-1][-1])


Measured memory_bytes: 50280
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int l[200005];
int sorted[200005];

int main() {
  int n;
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
    sorted[i] = l[i];
  }
  sort(sorted, sorted+n);
  for(int i = 0; i < n; i++) {
    if(l[i] <= sorted[n/2-1]) {
      printf("%d\n", sorted[n/2]);
    }
    else {
      printf("%d\n", sorted[n/2-1]);
    }
  }
}


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

int main(){
    int X,A,B; cin >> X >> A >> B;
    int temoto=X-A;
    int cnt=temoto/B;
    int ans=temoto-cnt*B;
    
    cout << ans;
    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int i,j,h,w;
while(1){
cin>>h>>w;
if(h==0 && w==0)break;
for(i=0;i<=h-1;i++){

for(j=0;j<=w-2;j++){
cout<<"#";
}
cout<<"#"<<endl;

}
cout<<endl;
}
return 0;
}


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

int cnt=0;

struct node{
  int key;
  struct node *parent;
  struct node *left;
  struct node *right;
};

typedef struct node *Nodepointer;

Nodepointer r,NIL;

void insert(int);
void print(void);

void inorder(Nodepointer);
void preorder(Nodepointer);

int find(int);

int main(){
  int i,n,num;
  char c[7];

scanf("%d",&n);
 
for(i=0;i<n;i++){
  scanf("%s",c);
  
  if(c[0]=='i'){
    scanf("%d",&num);
    insert(num);
  }
  else if(c[0]=='f'){
    scanf("%d",&num);
    if(find(num)==0)printf("no\n");
    else printf("yes\n");
  }
  else print();
 }
  return 0;
}

void insert(int k){
  Nodepointer y=NIL;
  Nodepointer x=r;

  Nodepointer z = (Nodepointer)malloc(sizeof(struct node));

  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }

  z->parent = y;

  if(y == NIL){
    r = z;
  }

  else if(z->key < y->key){
    y->left = z;
  }

  else{
    y->right = z;
  }

}

void print(void){
    inorder(r);
    printf("\n");
    preorder(r);
    printf("\n");
}

void inorder(Nodepointer a){
  if(a==NIL)return;
  inorder(a->left);
  printf(" %d",a->key);
  inorder(a->right);
}
void preorder(Nodepointer a){
  if(a == NIL){
    return;
  }
  printf(" %d",a->key);
  preorder(a->left);
  preorder(a->right);
}

int find(int k){
 Nodepointer T;
  T=r;
  while(T!=NULL && T->key!=k){
    if(k<T->key)T=T->left;
    else T=T->right;
  }
  
  if(T==NULL)return 0;
  else return 1;
}



Measured memory_bytes: 20612
import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def count(num):
    cnt = 0
    while num % 2 == 0:
        cnt += 1
        num //= 2
    return cnt


N, *a = map(int, read().split())
ans = 0
for i in a:
    ans += count(i)
print(ans)


Measured memory_bytes: 3956
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

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

int main()
{
    int n, m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << 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"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

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



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

	cin >> N >> M;
	cout << N - M + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    REP(i, SZ(s)) {
        if (s[i] == 'B') cnt++;
        else ans += cnt;
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 1356
import sys
input = sys.stdin.readline

N = int(input())
a = [list(input().rstrip()) for _ in range(N)]

ans = float('inf')
b = 0
for j in range(N):
    if any(a[i][j] == '.' for i in range(N)):
        b += 1
for i in range(N):
    if any(a[k][i] == '#' for k in range(N)):
        ans = min(ans, a[i].count('.') + b)
    elif any(a[i][k] == '#' for k in range(N)):
        ans = min(ans, a[i].count('.') + b + 1)
print(ans if ans < float('inf') else -1)

Measured memory_bytes: 83508
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int n;
  cin >> n;
  vi a(10,0);

  if(to_string(n)[1]!=to_string(n)[2]){
    cout << "No" << endl;
    return 0;
  }
  rep(i,4){
    a[n%10] += 1;
    n /= 10;
  }
  bool ans=false;
  rep(i,10) if(a[i]>=3) ans = true;
  cout << (ans ? "Yes" : "No") << endl; 
  return 0;
} 

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

const double PI = acos(-1.0);
int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double alpha = (H * 60 + M) / 720 * (PI * 2);
    double beta = M / 60 * (PI * 2);
    double theta = alpha - beta;
    double res = sqrt(A*A + B*B - 2.0*A*B*cos(theta));
    cout << fixed << setprecision(10) << res << endl;
}

Measured memory_bytes: 4224
#include <stdio.h>

int main(){

  long long int n,i,j,count=0,tmp;
  long long int a[100010];
  long long int b[100010];

  scanf("%lld",&n);

  for(i = 0; i < n; i++){
    scanf("%lld %lld",&a[i],&b[i]);
  }

  for(i = n-1; i >= 0; i--){
    a[i] += count;
    if(a[i]% b[i] != 0){
      tmp=b[i] - a[i] % b[i];
      count += tmp;
    }
  }
  printf("%lld\n",count);
  return 0;
}


Measured memory_bytes: 1664
temp = list(map(int, input().split()))
temp.sort()
a, b, c = temp[0], temp[1], temp[2]

if (2 * c - a - b) % 2 == 0:
    print((2 * c - a - b) // 2)
else:
    print((2 * c - a - b + 3) // 2)


Measured memory_bytes: 2940
from functools import reduce

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    

    if( a =='a' or a == 'i' or a =='u' or a == 'e' or a == 'o'):
        print('vowel')
    else:
        print('consonant')
        
if __name__ == '__main__':
    main()


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

using namespace std;

class item
{
public:
	int value;
	int weight;
};

bool input(int *c, int *n, item it[1000])
{
	cin>>*c;
	if(*c==0)
	{
		return false;
	}
	cin>>*n;
	for(int i=0;i<*n;i++)
	{
		char t;
		cin>>it[i].value>>t>>it[i].weight;
	}
	return true;
}

item max(item a, item b)
{
	if(a.value>b.value)
	{
		return a;
	}
	else
	{
		return b;
	}
}

item add(item a, item b)
{
	a.value+=b.value;
	a.weight+=b.weight;
	return a;
}

item solve(int c, int n, item it[1000])
{
	vector< vector<item> > table(n+1,vector<item>(c+1));
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=c;j++)
		{
			if(j==0||i==0)
			{
				table[i][j].value=0;
				table[i][j].weight=0;
			}
			else if(j<it[i-1].weight)
			{
				table[i][j]=table[i-1][j];
			}
			else
			{
				table[i][j]=max(table[i-1][j],add(table[i-1][j-it[i-1].weight],it[i-1]));
			}
		}
	}
	return table[n][c];
}

int main(void)
{
	int c,n;
	item it[1000];
	for(int i=1;input(&c,&n,it);i++)
	{	
		item ans=solve(c,n,it);
		cout<<"Case "<<i<<':'<<endl<<ans.value<<endl<<ans.weight<<endl;
	}
	return 0;
}

Measured memory_bytes: 8992
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main(void){
  int n,sum = 0,sum2 = 0,min = 10000;
  cin >> n;
  int *w = new int[n];
  for(int i = 0;i < n;i++){
    cin >> w[i];
    sum += w[i];
  }
  for(int j = 0;j < n;j++){
    sum2 += w[j];
    if(abs(sum2-(sum-sum2))<min){
      min = abs(sum2-(sum-sum2));
    }
  }
  cout << min;
  return 0;
}

Measured memory_bytes: 256
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define lld long long
#define llu unsigned long long

using namespace std;
int main()
{
	lld n,m,s;
	while(scanf("%lld%lld",&n,&m)!=EOF)
	{
		if(n>=2&&m>=2)
			s=(n-2)*(m-2);
		else if(n==1&&m>=2)
			s=m-2;
		else if(n>=2&&m==1)
			s=n-2;
		else if(n==1&&m==1)
			s=1;
		printf("%lld\n",s);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
    int h,w;
    while(1){
        cin >> h >> w;
        for(int i=0; i<h; i++){//heiht
            for(int j=0; j<w; j++){//width
                if(i!=0 && j!=0 && i!=(h-1) && j!=(w-1)){//h???0??????,w???0??????,h???n??????,w???n?????? 
                    cout << ".";
                }else{
                    cout << "#";
                }
            }
            cout << endl;
        }
        if(h==0&&w==0){
            return 0;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3016
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define MINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

string c[3];

void _main() {
    REP (i, 3) cin >> c[i];
    REP (i, 3) cout << c[i][i];
    cout << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
 
#define N 100010
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mod 1000000007
#define pii pair <ll, ll>
 
using namespace std;

ll x, k, d;

int main()
{
	cin >> x >> k >> d;
	
	x = abs(x);
	
	ll a = x/d;
	
	if(k < a) {
		cout << x - k*d;
		return 0;
	}
	
	k -= a;
	
	cout << abs(x-a*d - k%2*d);
}


Measured memory_bytes: 3220
n,k=map(int,input().split())
s=input()
sani=[]

for i in s:
    if not sani:
        sani.append([int(i),0,0])
    elif sani[-1][0]==int(i):
        sani[-1][2]+=1
    else:
        sani.append([int(i),sani[-1][2]+1,sani[-1][2]+1])

ans=0
left,right=0,0
zeroCnt=0

while right<len(sani):
    if zeroCnt<k or sani[right][0]==1:
        nowElem=sani[right]
        zeroCnt+=1 if sani[right][0]==0 else 0
        ans=max(ans,sani[right][2]-sani[left][1]+1)
        right+=1
    else:
        zeroCnt-=1 if sani[left][0]==0 else 0
        left+=1

print(ans)

Measured memory_bytes: 19700
#include<iostream>
using namespace std;
int main()
{
    int l,r,d;
    cin>>l>>r>>d;
    int i,count=0;
    for(i=l;i<=r;i++)
    {
        if(i%d==0)
            count++;
    }
    cout<<count<<endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, h, maxa = 0, btot = 0, cnt = 0, acnt;
  cin >> n >> h;
  vector<pair<ll, ll>> ba(n);
  rep(i, n) {
    cin >> ba[i].second >> ba[i].first;
    maxa = max(maxa, ba[i].second);
  }
  rep(i, n) if (ba[i].first > maxa) btot += ba[i].first;

  sort(ba.rbegin(), ba.rend());

  int i = 0;
  if (h <= btot) {
    while (h > 0) {
      h -= ba[i].first, ++i;
    }
    cnt = i;
  } else {
    acnt = ceil((h - btot) / (double)maxa);
    h -= acnt * maxa;
    while (h > 0) {
      h -= ba[i].first, ++i;
    }
    cnt = acnt + i;
  }

  cout << cnt << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

int A = 0, G = 1, C = 2, T = 3;

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

	int N;
	cin >> N;

	ll MOD = 1e9+7;

	ll dp[N+1][4][4][4];
	rep(i, N+1) rep(j, 4) rep(k, 4) rep(l, 4) dp[i][j][k][l] = 0;

	rep(j, 4) rep(k, 4) rep(l, 4){
		if(j == A && k == G && l == C) continue;
		if(j == A && k == C && l == G) continue;
		if(j == G && k == A && l == C) continue;
		dp[3][j][k][l] = 1;
	}

	for(int i = 4; i <= N; i++){
		rep(j, 4){
			rep(k, 4){
				rep(l, 4){
					rep(m, 4){
						if(j == A && k == G && l == C) continue;
						if(j == A && k == C && l == G) continue;
						if(j == G && k == A && l == C) continue;
						if(m == A && k == G && l == C) continue;
						if(m == A && j == G && l == C) continue;
						dp[i][j][k][l] += dp[i-1][m][j][k];
						dp[i][j][k][l] %= MOD;
					}
				}
			}
		}
	}

	ll ans = 0;
	rep(j, 4){
		rep(k, 4){
			rep(l, 4){
				ans += dp[N][j][k][l];
				ans %= MOD;
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >>n;
  n*=2;
  int c[n];
  for(int i=0;i<n;i++){
    cin>>c[i];
    }
  sort(c,c+n);
  int ans=0;
  for(int i=0;i<n;i+=2){
    ans+=c[i];
    }
  cout<<ans<<endl;
  return 0;
  }
  

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

int main() {
    int a[5];
    rep(i, 5) cin >> a[i];

    int ans = 1000;
    rep(i, 5) {
        int t = 0;
        rep(j, 5) {
            if (i == j) continue;
            t += a[j];
            while (t % 10 != 0) t++;
        }
        t += a[i];
        ans = min(ans, t);
    }

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


Measured memory_bytes: 256
object Main extends App {
  val n : Int = scala.io.StdIn.readInt
  val v : Seq[Int] = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val (voi, vei) : (Seq[(Int, Int)], Seq[(Int, Int)]) =
    v.zipWithIndex.partition(_._2 % 2 == 0)
  val Seq(mo, me) : Seq[Map[Int, Int]] =
    Seq(voi, vei).map(_.map(_._1).groupBy(identity).mapValues(_.length))
  val Seq(co, ce) : Seq[Seq[(Int, Int)]] =
    Seq(mo, me).map(_.toSeq.sortBy(- _._2))
  val good = {
    val Seq(go, ge) = Seq(co, ce).map(_.map(_._2))
    if(co.head._1 != ce.head._1) go.head + ge.head
    else Seq(
      go.head + ge.lift(1).getOrElse(0),
      go.lift(1).getOrElse(0) + ge.head
    ).max
  }
  println(n-good)
}


Measured memory_bytes: 115752
n = int(input())
t, a = map(int, input().split())
H = [int(i) for i in input().split()]
x = (t-a)/0.006

rs = 0
mid = 99999
for i in range(n):
    if mid > abs(x-H[i]):
        mid = abs(x-H[i])
        rs = i
print(rs+1)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int v[3], x=2, y=1;
    for(int i=0; i<3; i++){
        cin>>v[i];
        if(v[i]==5)
            x--;
        if(v[i]==7)
            y--;
    }
    if(x==0&&y==0)
        cout<<"YES";
    else
        cout<<"NO";


    return 0;
}


Measured memory_bytes: 256
def rec(i, x):
    if i >= length:
        return sum(list(map(int, x.split("+"))))
    return rec(i + 1, x + s[i + 1]) + rec(i + 1, x + "+" + s[i + 1])


s = input()
length = len(s) - 1
print(rec(0, s[0]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);cerr<<fixed<<setprecision(5);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
/* VARIABLE DECLARATION START */
int globe[int(1e6)];
/*  FUCNTION TEMPLATE STARTS  HERE */
double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
inline int maxm(const int &a,const int &b)
{
  if(a>b)return a;
  else return b;
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
/*  FUCNTION TEMPLATE ENDS HERE */

int main()
{
   VALHALLA
   string x;cin>>x;
   string s="aeiou";
   if(s.find(x)!=string::npos)
    cout<<"vowel"<<endl;
  else
    cout<<"consonant"<<endl;

}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define mod 1000000007
typedef long long LL;
int n,m;
LL f[5005][5005];
char s[5005];
int main()
{
	scanf("%d",&m);
	scanf("%s",s);
	n=strlen(s);
	f[0][0]=1;
	for(int j=1;j<=m;j++)
		for(int i=0;i<=m;i++)
		{
			if(i!=m)
				f[i][j]+=2ll*f[i+1][j-1];
			if(i==0)
				f[i][j]+=f[i][j-1];
			else
				f[i][j]+=f[i-1][j-1];
			f[i][j]%=mod;
		}
	printf("%lld",f[n][m]);
}

Measured memory_bytes: 195712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int inf = 1000000000;

ll pow(ll x,ll y){
  if(y == 0){
    return 1;
  }
  if(y == 1){
    return x;
  }
  if(y%2 == 0){
    return pow(x,y/2)*pow(x,y/2);
  }
  else{
    return x*pow(x,y/2)*pow(x,y/2);
  }
}

int main(){
    ll x;
    cin >> x;
    for(ll i=0; i<=1000; i++){
        for(ll j=-1000; j<=1000; j++){
            if(pow(i,5)-pow(j,5) == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}
    

Measured memory_bytes: 3996
package main

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

var scanner *bufio.Scanner

func printIt() {
	cnt := 1
	for {
		num := nextInt()
		if num != 0 {
			fmt.Printf("Case %d: %d\n", cnt, num)
		} else {
			break
		}
		cnt++
	}
}

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

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	printIt()
}



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

void fnInput(vector<int>& rvnDisk)
{
  int nDiskSiz;
  cin >> nDiskSiz;

  rvnDisk.resize(nDiskSiz);
  for (int i = 0; i < nDiskSiz; i++)
    cin >> rvnDisk[i];
}

int fnDiskCount(const vector<int>& cnrvnDisk)
{
  set<int> seDisk;

  for (int nDisk : cnrvnDisk)
    seDisk.insert(nDisk);

  return seDisk.size();
}

int main()
{
  vector<int> vnDisk;
  fnInput(vnDisk);
  cout << fnDiskCount(vnDisk) << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
  if A[i] % 2 != 0:
    pass
  elif A[i] % 3 != 0 and A[i] % 5 != 0:
    print("DENIED")
    sys.exit()
  else:
    pass
print("APPROVED")

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

void logic(char& status, const char op)
{
  if (status == '\0') {
    status = op;
  } else if (status == 'T' && op == 'F') {
    status = 'F';
  } else {
    status = 'T';
  }
}

int main()
{
  int n;
  char p;
  char status = '\0';

  cin >> n;
  while (n--) {
    cin >> p;
    logic(status, p);
  }

  cout << status << endl;
}



Measured memory_bytes: 3100
// Bismillahirrahmanirrahim
#include<bits/stdc++.h>
using namespace std;
vector<int> vec;

int main() {
		long long n;
		cin >> n;
		long long sq = sqrt(n);
		long long mx = (long long)1e13;
		for(long long i = 1; i <= sq; i++) {
			if(n%i == 0) {
				mx = min(n/i + i, mx);
			}
		}
		cout << mx - 2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int n;
    cin >> n;
    cout << "ABC" << n << endl;
    return 0;
}

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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		// String[] strArr = str.split("\\s+");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		char ans = str.charAt(0);
		ans++;
		System.out.println(ans);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 19796
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace A_PANA2020
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            int[] u = new int[32]{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            WriteLine(u[s[0]-1]);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
const int MOD = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<ll> mod2(60,1);
  for (int i=1;i < 60;i++){
    mod2.at(i) = (2 * mod2.at(i-1)) % MOD;
  }
  ll a;
  vector<bitset<60>> bita(N);
  for (int i=0;i<N;i++){
    cin >> a;
    bitset<60> tmp(a);
    bita.at(i) = tmp;
  }
  vector<ll> n0x1(60);
  for (int i=0;i<60;i++){
    ll cnt=0;
    for (int j=0;j<N;j++){
      if (bita.at(j).test(i)) cnt++;
    }
    n0x1.at(i) = (cnt * (N - cnt)) % MOD;
  }
  ll ans=0;
  for (int i=0;i<60;i++){
    ans = (ans + ((mod2.at(i) * n0x1.at(i)) % MOD)) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX_N 100001


/* -----------------------------------------------------------------------------
	型とクラス定義
----------------------------------------------------------------------------- */

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int A;	// 窓の横方向の長さ
int B;	// カーテンの横方向の長さ

int main () {

	// 個数と長さの読込み
	scanf("%d %d", &A, &B);

	if(A < 10 && B < 10)
		printf("%d\n", A * B);
	else
		printf("%d\n", -1);

	return 0;
}

Measured memory_bytes: 128
INF = 10 ** 9
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  heapq import heappop,heapify,heappush
from bisect import bisect_left

def main():
    s = input()
    for bit in range(8):
        op = []
        for i in range(3):
            if (bit>>i)&1:
                op.append('+')
            else:
                op.append('-')
        
        tmp = s[0]
        for i in range(3):
            tmp += op[i]
            tmp += s[i + 1]

        if eval(tmp) == 7:
            ans = tmp + '=7'
            break
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
N, M = map(int, input().split())
X = list(map(int, input().split()))

if N >= M:
    print(0)
    exit()

X = sorted(X)
# print(X)
d = [X[i + 1] - X[i] for i in range(len(X) - 1)]
d = sorted(d)
# print('d', d)
if N == 1:
    print(sum(d))
else:
    print(sum(d[:-N + 1]))


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

int main(){
  int n,sum=0;
  cin>>n;
  int a[25],b[25],c[25];
  for(int i=1;i<=n;i++){
    cin>>a[i];
  }
  for(int i=1;i<=n;i++){
    cin>>b[i];
  }
  for(int i=1;i<=n-1;i++){
    cin>>c[i];
  }
  for(int i=1;i<=n;i++){
    sum+=b[a[i]];
    if(i>1&&a[i]-a[i-1]==1){
      sum+=c[a[i-1]];
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 256
using System;

namespace A___HEX
{
    class Program
    {
        static void Main(string[] args)
        {
            var X_Y = Console.ReadLine().Split();
            var X = X_Y[0];
            var Y = X_Y[1];

            if (string.Compare(X, Y) == 0)
                Console.WriteLine("=");
            else if (string.Compare(X, Y) > 0)
                Console.WriteLine(">");
            else
                Console.WriteLine("<");
        }
    }
}


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

int i, j, k, t = 1, p = 0, m = 1e9+7, r = 0, a[2019];
char s[200001];

int main() {
    scanf("%s",s);

    for(i = 0; s[i] != '\0'; i++);
    for(j =-- i; i >= 0; i--) {
        p = (p + (s[i] - 48) * t) % 2019;
        t = (t * 10) % 2019;
        a[p]++;
    }
    for(i = 0; i < 2019; i++) {
        r += a[i] * (a[i] - 1) / 2;
    }
    printf("%d",r + a[0]);
    return 0;
}


Measured memory_bytes: 1844
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define debug(x) cout << "> x:" << x << endl;
#define len(x) int(x.size())
#define all(x) x.begin(), x.end()
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	vector<int> vs(n);
	for(int i=0; i<n; ++i) vs[i]=i+k;
	int l = vs[0], r=vs[n-1];
	int ans=0;
	for(int i=0; i<n; ++i){
		ans+=vs[i];
	}
	if(l<0 and r<0)
		ans-=vs[n-1];
	else if(l>0 and r>0)
		ans-=vs[0];
	cout << ans << endl;
}	


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793

int main(){
	int k, s;
	int count=0;
	scanf("%d%d", &k, &s);
	for(int y=0; y<=k; y++){
		for(int z=0; z<=k; z++){
			if((y+z>=s-k) && (y+z<=s)){
				count++;
			}
		}
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N,K;
vector <int > H;
string s,a;




int main()
{

	cin >> s;

	REP(i,s.size()){
		switch(s[i]){
		case '0':
		case '1':
			a.push_back(s[i]);
			break;
		case 'B':
			if(!a.empty())
				a.erase(a.end() - 1);
			break;
		}
	}
	cout << a << endl;




}


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

#define REP(i, s, n) for(int i = (s); i < int(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(co) co.begin(), co.end()

int dp[1002][1002];
int dist[1000];
int cs[1000];

int main()
{
	int n, m; cin >> n >> m;
	rep(i, n) cin >> dist[i];
	rep(i, m) cin >> cs[i];
	rep(i, m + 1) rep(j, n + 1) dp[i][j] = (1 << 29);

	dp[0][0] = 0;
	rep(i, m) rep(j, n)
	{
		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		dp[i + 1][j + 1] = min(dp[i + 1][j + 1], dp[i][j] + dist[j] * cs[i]);
	}

	int ans = (1 << 29);
	rep(i, m + 1) ans = min(ans, dp[i][n]);

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 6940
$N=<>;
for$i(1..$N){
	for$p(grep{(1x$_)!~/^(11+)\1+$/}2..$N){
		$g[$p]+=grep{$i%$p**$_<1}1..6
	}
}
for$a(1..$N){
	$z+=$g[$a]>73;
	for$b(2..$N){
		if($a!=$b){
			$z+=$g[$a]>3&&$g[$b]>13;
			$z+=$g[$a]>1&&$g[$b]>23;
			for$c($b+1..$N){
				if($a!=$c){
					$z+=$g[$a]>1&&$g[$b]>3&&$g[$c]>3;
				}
			}
		}
	}
}
print$z


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

typedef long long ll;

int main (int argc, char* argv[]) {
	ll n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	vector<ll> range_sums;
	if (s[0] == '0') {
		range_sums.push_back(0);
	}
	for (ll i = 0; i < n; i++) {
		if (i == 0 || s[i - 1] != s[i]) {
			range_sums.push_back(1);
		} else {
			range_sums.back()++;
		}
	}
	if (s.back() == '0') {
		range_sums.push_back(0);
	}

	ll c_sum = 0;
	ll w_size = k * 2 + 1;
	for (ll i = 0; i < w_size && i < range_sums.size(); i++) {
		c_sum += range_sums[i];
	}
	ll max_sum = c_sum;
	for (ll i = w_size; i < range_sums.size(); i++) {
		c_sum -= range_sums[i - w_size];
		c_sum += range_sums[i];
		if (!(i & 1)) {
			max_sum = max(max_sum, c_sum);
		}
	}
	cout << max_sum << endl;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int main() {
  int n;
  while(cin >> n && n) {
    int cnt=0;
    for(int i=1; i<=1000; i++) {
      int sum=i;
      for(int j=1; j<=1000; j++) {
	sum+=i+j;
	if(sum>n) break;
	if(sum==n) cnt++;
      }
    }
    pr(cnt);
  }
  return 0;
}


Measured memory_bytes: 1160
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int N = sc.nextInt();
		int[] a = new int[N];
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		
		int[] left = new int[N + 1];
		int[] right = new int[N + 1];
		for(int i = 0; i < N; i++) left[i + 1] = gcd(left[i], a[i]);
		for(int i = N - 1; i >= 0; i--) right[i] = gcd(right[i + 1], a[i]);
		
		int res = 0;
		for(int i = 0; i < N; i++) {
			int l = left[i];
			int r = right[i+1];
			
			res = Math.max(res, gcd(l,r));
		}
	  out.println(res);
		
		out.close();
	}
	  private static int gcd(int m, int n) {
		    if(m < n) return gcd(n, m);
		    if(n == 0) return m;
		    return gcd(n, m % n);
		}

static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
}




Measured memory_bytes: 25056
#include <iostream>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int H, W; cin >> H >> W;
	char S[50][50];
	char T[50][50];
	rep(i, 0, H) {
		cin >> S[i];
	}

	rep(i, 0, H) {
		rep(j, 0, W) {
			T[i][j] = S[i][j];
		}
	}
	int h[8] = { 0,1,-1,1,-1,0,1,-1 };
	int w[8] = { 1,1,1,0,0,-1,-1,-1 };

	rep(i, 0, H) {
		rep(j, 0, W) {
			if (S[i][j] == '#') {
				T[i][j] == '#';
				continue;
			}
			int count = 0;
			rep(k, 0, 8) {
				int dh = i + h[k];
				int dw = j + w[k];
				if (dh >= 0 && dh <= H - 1 && dw >= 0 && dw <= W - 1) {
					if (S[dh][dw] == '#') {
						count++;
					}
				}
			}
			T[i][j] = (char)(count + '0');
		}
	}

	rep(i, 0, H) {
		rep(j, 0, W) {
			cout << T[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

long long calc(long long n)
{
	n++;

	long long ret = 0;
	for (int i = 0; i < 50; i++) {
		long long cycle = 1LL << (i + 1);
		long long cnt1 = (n / cycle) * (cycle / 2);
		cnt1 += max(0LL, n%cycle - cycle / 2);

		if (cnt1 % 2 == 1)
			ret += 1LL << i;
	}

	return ret;
}

int main(void)
{
	long long A, B;
	cin >> A >> B;

	long long a = calc(A - 1);
	long long b = calc(B);
	long long ans = a ^ b;
	cout << ans << endl;

	return 0;
}


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

int main() {
  int a,b,c=0;
  cin>>a>>b;
  for(int i=a;i<b+1;i++){
    int c5=i%10;
    int c4=(i%100-c5)/10;
    int c2=(i%10000-i%1000)/1000;
    int c1=(i-i%10000)/10000;
    if(c1==c5&&c2==c4) c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
attrs = Array.new
while line = $stdin.gets
  attrs << line.chomp.split
end

A, B = attrs[0].map{|a| a.to_i}

r8 = 0.08
r10 = 0.1
x1 = A/r8
x2 = B/r10
x = [x1,x2].min.to_i
flag = true
res = -1
while (flag) do
  p8 = (x * r8).floor
  p10 = (x * r10).floor
  if (p8 == A && p10 == B) then
    flag = false
    res = x
  elsif (p8 > A || p10 > B) then
    flag = false
  else
    x += 1;
  end
end
puts res

Measured memory_bytes: 1788
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 1e5 + 10;
int p[MAXN],q[MAXN],r[MAXN];
int A,B,C; 
int X,Y;

pair<int,pair<int,int>> a[2*MAXN];

bool cmp(pair<int,pair<int,int>> xx,pair<int,pair<int,int>> yy){
    if(xx.f == yy.f) return xx.s.s < yy.s.s;
    else return xx.f > yy.f;
}

void solve(){
    cin>>X>>Y>>A>>B>>C;
    FOR(i,1,A) cin>>p[i];
    FOR(i,1,B) cin>>q[i];
    FOR(i,1,C) cin>>r[i];

    sort(p+1,p+A+1); reverse(p+1,p+A+1);
    sort(q+1,q+B+1); reverse(q+1,q+B+1);
    sort(r+1,r+C+1); reverse(r+1,r+C+1);
    
    FOR(i,1,B) a[i].f = q[i],a[i].s.f = 0,a[i].s.s = i;
    FOR(i,1,C) a[i+B].f = r[i],a[i+B].s.f = 1,a[i+B].s.s = 0;
    
    sort(a+1,a+B+C+1,cmp);

    FOR(i,1,A) p[i] = p[i-1] + p[i];
    FOR(i,1,B) q[i] = q[i-1] + q[i];
    FOR(i,1,C) r[i] = r[i-1] + r[i];

    FOR(i,1,B+C) a[i].f += a[i-1].f,a[i].s.f += a[i-1].s.f,a[i].s.s = max(a[i].s.s,a[i-1].s.s);

    int ans = 0;
    FOR(i,0,X){
        if(X-i > C) continue;
        // clog<<i<<" ";
        int temp = p[i];
        int tot_left = X+Y-i;
        // clog<<tot_left<<" "<<a[tot_left].f<<" ";
        if(a[tot_left].s.f >= X-i){
            temp = temp + a[tot_left].f;
        }else {
            temp = temp + a[tot_left].f;
            int idx = a[tot_left].s.s;
            int leftt = X - i - a[tot_left].s.f;
            temp = temp + r[a[tot_left].s.f + leftt] - r[a[tot_left].s.f];
            temp = temp - (q[idx] - q[idx-leftt]);
        }
        // clog<<temp<<endl;
        ans = max(ans,temp);
    }
    cout<<ans<<endl;
}

signed main(){

   FastRead;    


    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 7296
n=int(input())
xl=[]

for i in range(n):
    x,l=list(map(int,input().split()))
    xl.append([x-l,x+l,x])

xl.sort(key=lambda x: x[1])

armmax=-10**10
cnt=0
for left,right,x in xl:
    if armmax<=left:
        armmax=right
        cnt+=1

print(cnt)


Measured memory_bytes: 24896
import copy

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

chinpo = max(A)
B = copy.copy(A)
B.remove(max(A))
chinchin = max(B)

for i in range(A.index(max(A))):
    print(chinpo)
print(chinchin)
for i in range(A.index(max(A))+1,N):
    print(chinpo)


Measured memory_bytes: 14560