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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(100000 + 2 + 1, 0);
    for (int i = 0; i < n; ++i) {
        int a;
        int b;
        cin >> a >> b;
        v[b + 1] -= 1;
        v[a] += 1;
    }

    for (int i = 1; i < v.size() - 1; ++i) {
        v[i] = v[i - 1] + v[i];
    }
    int max_{0};
    for (int i = 0; i < v.size(); ++i) {
        if (v[i] != 0 && (i - 1) <= v[i]) {
            max_ = i;
        }
    }
    if (max_ != 0) {
        cout << (max_ - 1) << endl;
    }
    else {
        cout << max_ << endl;
    }
}

Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

#define MAXN 20005
#define MAXE 40005
#define INF 0x3f3f3f3f

typedef int Type;

class Dijkstra
{
public:
    int head[MAXN],nxt[MAXE],cnt;
    Type d[MAXN];
    struct Edge
    {
        int v;
        Type dis;
        Type cost;
        Edge() {}
        Edge(int v,Type dis,Type cost):v(v),dis(dis),cost(cost) {}
        bool operator<(const Edge& ed) const
        {
            return dis>ed.dis;
        }
    } e[MAXE];
    bool vis[MAXN];

    //初始化，n?点数
    void init(int n)
    {
        cnt = 0;
        for(int i = 0; i<=n; i++) head[i] = -1;
    }

    inline void addEdge(int u,int v,Type dis,Type cost)
    {
        e[cnt] = Edge(v,dis,cost);
        int tmp = head[u];
        head[u] = cnt;
        nxt[cnt++] = tmp;
    }

    void dijkstra(int s,int t,int n)
    {
        for(int i = 0; i<=n; i++) d[i] = INF,vis[i] = false;
        d[s] = 0;
        priority_queue<Edge> q;
        q.push(Edge(s,0,0));
        while(!q.empty())
        {
            Edge ed = q.top();
            q.pop();
            vis[ed.v] = true;
            for(int i = head[ed.v]; ~i; i = nxt[i])
            {
                Edge ee = e[i];
                if(!vis[ee.v]&&d[ee.v]>d[ed.v]+ee.dis)
                {
                    d[ee.v] = d[ed.v]+ee.dis;
                    /*
                     *  最短路?
                    	p[ee.v] = MP(u,i);
                    */
                    q.push(Edge(ee.v,d[ee.v],ee.cost));
                }
            }
        }
    }

    void buildGraph(int m)
    {
        for(int i=0; i<m; i++)
        {
            int u,v,d,c;
            scanf("%d%d%d%d",&u,&v,&d,&c);
            addEdge(u,v,d,c);
            addEdge(v,u,d,c);
        }
    }

    Type getMinCost(int n)
    {
        int ans=0;
        for(int u=2; u<=n; u++) //首都不能?
        {
            int Min=INF;
            for(int j=head[u]; ~j; j=nxt[j])
            {
                Edge ee = e[j];
                if(d[u]==d[ee.v]+ee.dis && ee.cost<Min) //找??足?先距?最短，然后?用最低的那个最低?用
                    Min=ee.cost;
            }
            ans+=Min;
        }
        return ans;
    }
} dij;

int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        if(n==0 && m==0)
            break;
        dij.init(n);
        dij.buildGraph(m);
        dij.dijkstra(1,n,n);
        int ans=dij.getMinCost(n);
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
int n,k,h[100105],dp[100105];
int solve(int idx){
    if(idx > n - 1)
        return 1e9;
    if(idx == n - 1)
        return 0;
    int &ans = dp[idx];
    if(ans != -1)
        return ans;
    ans = 1e9;
    for(int i = 1; i <= k; i++)
        ans = min(ans, abs(h[idx] - h[idx + i]) + solve(idx + i));
    return ans;
}
int main()
{
    ios::sync_with_stdio(0);
    memset(dp , -1 ,sizeof dp);
    cin >> n >> k;
    for(int i = 0; i < n; i++)
        cin >> h[i];
    cout << solve(0) << endl;
}


Measured memory_bytes: 5760
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
const ll MAX_N = 3000;
/**/
int main() {
	// 入力
	ll K,A,B;cin>>K>>A>>B;
	
	// 解法 
	bool ans = false;
	for (ll i = A; i <= B; ++i){
		if (i%K==0) ans = true;
	}
	//出力
	if (ans) printf("OK\n");
	else printf("NG\n");
}


Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long i64;
const int P=1e9+7;
const int N=1e6+6;

int inv[N],iinv[N];

int pwr(int x,int a){
	int s=1;
	while(a){
		if(a&1)s=(i64)s*x%P;
		x=(i64)x*x%P;
		a>>=1;
	}
	return s;
}

int C(int n,int m){
	return (i64)inv[n]*iinv[m]%P*iinv[n-m]%P;
}

int main()
{
	int n,a,b,c,i,x,ans=0;
	cin>>n>>a>>b>>c;
	inv[0]=1;
	for(i=1;i<=2*n;i++)
		inv[i]=(i64)inv[i-1]*i%P;
	iinv[2*n]=pwr(inv[2*n],P-2);
	for(i=2*n;i;i--)
		iinv[i-1]=(i64)iinv[i]*i%P;
	x=pwr(100,P-2);
	a=(i64)a*x%P;
	b=(i64)b*x%P;
	c=(a+b)%P;
	x=pwr(c,P-2);
	a=(i64)a*x%P;
	b=(i64)b*x%P;
	for(i=0;i<n;i++){
		ans+=(i64)x*(n+i)%P*C(n-1+i,i)%P*pwr(a,i)%P*pwr(b,n)%P;
		ans%=P;
		ans+=(i64)x*(n+i)%P*C(n-1+i,i)%P*pwr(a,n)%P*pwr(b,i)%P;
		ans%=P;
	}
	//ans=(i64)ans*pwr(2,P-2)%P;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#include <math.h>

int main() {

	long long n, k, ans;

	cin >> n >> k;

	ans = n%k;

	if (ans > k - ans) {
		ans = k - ans;
	}

	cout << ans;

	cin >> ans;

	return 0;


}

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

int main(){
  int N, M;
  cin >> N >> M;
  int a, b;
  vector<int> x(N,0);
  for(int i = 0; i < M; i++){
    cin >> a >> b;
    for(int j = 0; j < N; j++){
      if(a == j + 1||b == j + 1){
        x[j]++;
      }
    }
  }
  for(int j = 0; j < N; j++){
    cout << x[j] << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int k=0;
	while(a>0 && c>0){
            if(k%2==0){
                c-=b;
                k++;
            }
            else{
                a-=d;
                k++;
            }

	}
	if(a<=0){
        cout<<"No";
	}
	else
        cout<<"Yes";

}


Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main() {
    int n,m;
    cin >> n >> m;
    int pop = 0;
    double a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    double total_votes = 0;
    for (int i = 0; i < n; i++) total_votes += a[i];
    double req = total_votes * (0.25)/m; 
    for (int i = 0; i < n; i++) {
        if (a[i] >= req) pop++;
        if (pop == m) break;
    }
    if (pop == m) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 2e5 + 5, M = 2 * N + 5;

int n, a[N];
ll dp[N][3];

ll solve(int i, int rem){
    if(i >= n)return (rem == 2 && (n & 1)) ? -1e17 : 0;
    ll &ret = dp[i][rem];
    if(~ret)return ret;
    ret = -1e17;
    ret = max(ret, solve(i + 2, rem) + a[i]);
    if(rem)
        ret = max(ret, solve(i + 1, rem - 1));
    return ret;
}

int main(){
    scanf("%d", &n);
    for(int i = 0 ; i < n ; ++i)
        scanf("%d", a + i);
    memset(dp, -1 , sizeof dp);
    printf("%lld\n", solve(0, (n & 1) + 1));
}

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

int main(){
    int n;
    cin >> n;
    vector<int> R(n);
    for (int i = 0; i < n; i++){
        cin >> R[i];
    }
    
    int maxv = R[1]-R[0], minv = R[0];
    for (int j = 1; j < n; j++){
        maxv = max(maxv, R[j]-minv);
        minv = min(minv, R[j]);
    }
    cout << maxv << endl;
}


Measured memory_bytes: 3628
#include <iostream>                                                      
using namespace std;                                                     
                                                                         
int main() {                                                             
  while (true) {                                                         
    int H, W;                                                            
    cin >> H >> W;                                                       
    if (H==0 && W==0) {                                                  
      break;                                                             
    }                                                                    
    for (int i=0; i<H; i++) {                                            
      for (int j=0; j<W; j++) {                                          
        cout << "#" << flush;                                            
      }                                                                  
      cout << endl;                                                      
    }                                                                    
    cout << endl;                                                        
  }                                                                      
  return 0;                                                              
}                                                                        
                                                                         
                                                                         
                                                                         
                                                                         
                                                                         
                     

Measured memory_bytes: 3008
#include <iostream>
#include <string>

using namespace std;

int main() {
    int N, K;
    long long int R, S, P;
    string str;
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> str;
    
    long long int ans=0;
    for(int i=0; i<N; i++) {
        if(str[i]=='r') {
            ans+=P;
            if(i+K<N && str[i+K]=='r') {
                str[i+K] = 'n';
            }
        } else if(str[i]=='s') {
            ans+=R;
            if(i+K<N && str[i+K]=='s') {
                str[i+K] = 'n';
            }
        } else if(str[i]=='p') {
            ans+=S;
            if(i+K<N && str[i+K]=='p') {
                str[i+K] = 'n';
            }
        }
    }
    
    cout << ans << endl;


    return 0;
    
}

Measured memory_bytes: 640
n, y = gets.chomp.split.map(&:to_i)
 
0.upto(n) do |i|
  0.upto(n-i) do |j|
    money = i * 10000 + j * 5000 + (n-i-j) * 1000
    if money == y
      puts [i, j, n-i-j].join(' ')
      exit
    end
  end
end
 
puts '-1 -1 -1'

Measured memory_bytes: 1788
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

string s, t;

int ss[100010];
int st[100010];

int n, m;

int main(){

  s = stin();
  t = stin();

  n = SZ(s);
  m = SZ(t);

  REP( i , n ){
    if( s[i] == 'A' ){
      ss[i+1] = ss[i] + 1;
    } else {
      ss[i+1] = ss[i] - 1;
    }
  }

  REP( i , m ){
    if( t[i] == 'A' ){
      st[i+1] = st[i] + 1;
    } else {
      st[i+1] = st[i] - 1;
    }
  }

  int q = in();
  REP( i , q ){
    int a = in() - 1;
    int b = in();
    int c = in() - 1;
    int d = in();
    int x = ss[b] - ss[a];
    int y = st[d] - st[c];
    if( ( x - y ) % 3 == 0 ){
      puts( "YES" );
    } else {
      puts( "NO" );
    }
  }
  

  return 0;
}


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

int main(){

  int n, x, y, m, l;
  char d;

  while(cin>>n, n){
    bool p[21][21]={};
    for(int i=0;i<n;i++){
      cin>>x>>y;
      p[y][x]=true;
    }
    cin>>m;
    int nx=10, ny=10;
    for(int i=0;i<m;i++){
      cin>>d>>l;
      if(d=='N'){
	for(int j=0;j<l;j++){
	  ny++;
	  if(p[ny][nx]==true){
	    n--;
	    p[ny][nx]=false;
	  }
	}
      }else if(d=='E'){
	for(int j=0;j<l;j++){
	  nx++;
	  if(p[ny][nx]==true){
	    n--;
	    p[ny][nx]=false;
	  }
	}
      }else if(d=='S'){
	for(int j=0;j<l;j++){
	  ny--;
	  if(p[ny][nx]==true){
	    n--;
	    p[ny][nx]=false;
	  }
	}
      }else if(d=='W'){
	for(int j=0;j<l;j++){
	  nx--;
	  if(p[ny][nx]==true){
	    n--;
	    p[ny][nx]=false;
	  }
	}
      }
    }
    if(n) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll w, h, n;
    cin >> w >> h >> n;

    ll left = 0, right = w;
    ll shita = 0, ue = h;
    rep(i, n) {
        ll x, y, a;
        cin >> x >> y >> a;
        if(a == 1) {
            chmax(left, x);
        }
        else if(a == 2) {
            chmin(right, x);
        }
        else if(a == 3) {
            chmax(shita, y);
        }
        else if(a == 4) {
            chmin(ue, y);
        }
    }

    if(right <= left || ue <= shita) {
        out(0);
    }
    else {
        out( (right - left)*(ue - shita) );
    }
    
    re0;
}

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

int main(){
    ll a,b,c,k; cin >> a >> b >> c >> k;
    ll ans = 0;

    if(k <= a) ans += k;
    else if(k <= a+b) ans += a;
    else ans += a - min(k-a-b,c);

    cout << ans << endl;

}

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

using namespace std;

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

using ll = long long;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<tuple<string, int, int> > v;
	rep (i, n) {
	  string s;
	  int p;
	  cin >> s >> p;
	  v.emplace_back(s, -p, i + 1);
	}
	sort(v.begin(), v.end());
	rep (i, n) cout << get<2>(v[i]) << endl;
	
    return 0;
}


Measured memory_bytes: 3668
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define absl(v) labs((v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
void initialize(){
    
}
ll find(ll a,ll c){
  return a/c;
}
ll lcm(ll a,ll b){ return (a/gcd(a,b))*b;}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  ll a,b,c,d;
  char s[LIMIT1];
  
  scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
  result = b-a+1;
  result -= find(b,c)-find(a-1,c);
  result -= find(b,d)-find(a-1,d);
  result += find(b,lcm(c,d))-find(a-1,lcm(c,d));
  printf("%lld\n",result);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
  int N,M,C;
  cin >> N >> M >> C;
  vector<int> B(M);
  vector<int> A(M);
  for(int i=0;i<M;i++){
    cin >> B[i];
  }
  int ans=0;
  for(int i=0;i<N;i++){
    int sum=C;
    for(int j=0;j<M;j++){
      cin >> A[j];
      sum += B[j]*A[j];
    }
    if(sum>0)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from sys import stdin
def ii(): return int(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def li(): return list(mi())
n=ii()
x=min(9, n)
if n>99:
    x+=min(900, n-99)
    if n>9999:
        x+=min(90000, n-9999)
print(x)

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll N; cin >> N;
    if(N%2) cout << 2*N << endl;
    else cout << N << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

int main() {
  int n; cin>>n;
  vector<int> v(n);
  rep(i,n) cin>>v[i];
  int prev = v[0];
  int ans=0;
  int cnt=1;
  for(int i=1; i<=n-1; i++) {
    if(v[i]==prev) cnt++;
    else {
      ans+=cnt/2;
      cnt=1;
      prev=v[i];
    }
  }
  ans+=cnt/2;
  cout <<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, k = list(map(int, readline().split()))
    while n > divmod(n, k)[1]:
        n = divmod(n, k)[1]
    print(min(n, abs(n - k)))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
import java.util.*;
/**
 * @author afterCmidday
 *
 */
class Main {
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO 自動生成されたメソッド・スタブ
        final double eps = 1e-10;
        int n;
        Scanner scan = new Scanner(System.in);
        n = scan.nextInt();
        for(int i = 0;i < n;i++){
            double x1 = scan.nextDouble(), y1 = scan.nextDouble(), x2 = scan.nextDouble(), y2 = scan.nextDouble();
            double a = x2 - x1, b = y2 - y1;
            double x3 = scan.nextDouble(), y3 = scan.nextDouble(), x4 = scan.nextDouble(), y4 = scan.nextDouble();
            double c = x4 - x3, d = y4 - y3;
            double e = a * d - b * c;
            if(Math.abs(e) < eps){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }
 
    }
 
}


Measured memory_bytes: 30696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

vector<vector<char>> ans;
void p(int lu,int si){//左上がlu,lu 大きさがsi
    if(si==9){
        rep(i,6){
            if(i==2 || i==3){
                ans[lu+i][lu+0]='b';
                ans[lu+i][lu+1]='a';
                ans[lu+i][lu+2]='b';
            }
            else{
                ans[lu+i][lu+0]='a';
                ans[lu+i][lu+1]='b';
                ans[lu+i][lu+2]='a';
            }
        }
        for(int i=lu+6;i<lu+9;i++){
            for(int j=lu+3;j<lu+9;j++){
                if(i==lu+7){
                    if(j==lu+5 || j==lu+6){
                        ans[i][j]='a';
                    }
                    else ans[i][j]='b';
                }
                else{
                    if(j==lu+5 || j==lu+6){
                        ans[i][j]='b';
                    }
                    else ans[i][j]='a';
                }
            }
        }
        return;
    }
    if(si%3==0){
        for(int i=lu;i<si;i+=3){
            ans[i][i]='a';
            ans[i][i+1]='a';
            ans[i+1][i+2]='a';
            ans[i+2][i+2]='a';
        }
        return;
    }
    if(si==4){
        vector<string> sample={"abaa","abcc","ccba","aaba"};
        rep(i,4)rep(j,4){
            ans[lu+i][lu+j]=sample[i][j];
        }
        return;
    }
    if(si==5){
        vector<string> sample={"abbaa","ac..b","bc..b","b.cca","aabba"};
        rep(i,5)rep(j,5){
            ans[lu+i][lu+j]=sample[i][j];
        }
        return;
    }
    if(si==7){
        vector<string> sample={"aba....","aba....","bab....","bab....","a..aabb","a..bbaa",".bbaabb"};
        rep(i,7)rep(j,7){
            ans[lu+i][lu+j]=sample[i][j];
        }
        return;
    }
    if(si==8){
        p(lu,4);
        p(lu+4,4);
        return;
    }
    if(si==10){
        p(lu,5);
        p(lu+5,5);
        return;
    }
    if(si==11){
        p(lu,4);
        p(lu+4,7);
        return;
    }
    if(si>=13){
        p(lu,si-9);
        p(lu+si-9,9);
        return;
    }
}

int main() {
    int N;
    cin>>N;
    if(N==2){cout<<-1<<endl;return 0;}
    ans.resize(N,vector<char>(N,'.'));
    p(0,N);
    rep(i,N){
        rep(j,N){
            cout<<ans[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 4684
import sys
sys.setrecursionlimit(10**9)
from collections import deque
K = int(input())
queue = deque([1,2,3,4,5,6,7,8,9])
def rec(queue,i):
    x = queue[i]
    if x >= 3234566667:
        return queue
    r = x % 10
    if (r != 0):
        new_x = x * 10 + (r) - 1
        queue.append(new_x)
    new_x = x * 10 + (r)
    queue.append(new_x)
    if (r != 9):
        new_x = x * 10 + r + 1
        queue.append(new_x)
    return rec(queue,i+1)
res = rec(queue,0)
print(res[K-1])

Measured memory_bytes: 110516
#include <stdio.h>

int main()
{   int x,y,ans=0;
    scanf("%d%d",&x,&y);
    if(x==1){
        ans+=300000;
    }else if(x==2){
        ans+=200000;
    }else if(x==3){
        ans+=100000;
    }
    if(y==1){
        ans+=300000;
    }else if(y==2){
        ans+=200000;
    }else if(y==3){
        ans+=100000;
    }
    if(ans==600000)ans+=400000;
    
    printf("%d",ans);

    return 0;
}


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

class Program {
    static void Main(string[] args) {
        int[] inp = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int N = inp[0];
        int K = inp[1];
        int[] A = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var dic = new Dictionary<int, int>();

        for (int i = 0; i < N; i++) {
            if (dic.Keys.Contains(A[i])) {
                dic[A[i]]++;
            } else {
                dic.Add(A[i], 1);
            }
        }

        if (dic.Distinct().Count() <= K) {
            WriteLine(0);
            return;
        }

        //for (int i = 0; i < K; i ++) {
        //    dic.Remove(dic.Where(kvp => kvp.Value == dic.Values.Max()).First().Key);
        //}

        WriteLine(dic.Values.OrderBy(v => -v).Skip(K).Sum());
    }
}



Measured memory_bytes: 39632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll INF = 1LL<<60;
/////////////////////////////////
int main(){
    int a,b;
    cin >> a >> b;
    if(a<10 && b<10)
        cout << a * b << endl;
    else
        cout << -1 << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
using namespace std;
#define INFTY ( 1 << 28 )
#define rep(i,n) for(int i=0;i<n;i++)
int W,H,mas[10][10],f,m,o,ret,min_cost[10][10][50];
void solve(int y,int x,int bit,int air,int cost){
  if(air <= 0) return;
  if(!(bit >> x & 1)){
    if(mas[y][x] > 0) air = min(m,air + mas[y][x]);
    else cost -= mas[y][x];
    bit |= 1 << x;
  }
  if(cost > f || min_cost[y][x][air] <= cost) return;
  min_cost[y][x][air] = cost;
  if(y == H - 1){
    ret = min(ret,cost);
    return;
  }
  solve(y+1,x,0,--air,cost);
  if(x + 1 < W) solve(y,x+1,bit,air,cost);
  if(x - 1 >= 0) solve(y,x-1,bit,air,cost);
}
int main(){
  while(cin >> W >> H , W){
    fill_n(min_cost[0][0],5000,INFTY),ret = INFTY;
    cin >> f >> m >> o;
    rep(i,H) rep(j,W) cin >> mas[i][j];
    rep(i,W) solve(0,i,0,o-1,0);
    if(ret == INFTY) cout << "NA" << endl;
    else cout << ret << endl;
  }
}

Measured memory_bytes: 1184
#include <iostream>
using namespace std;
 
int main() 
{
	int n;
	cin >> n; 	
	cout << (n==1 || n==2 || n==3 || n==5 || n==6 || n==9 || n==10 || n==13 || n==17 ? "No" : "Yes") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef unsigned long long ll;

int main()
{
  ll A,B,i,j; cin>>A;
  ll answer1[A];ll answer2[A];
  for(i=0;i<A;i++){cin>>B;answer1[i]=B;answer2[i]=B;}
  sort(answer1,answer1+A);
  ll maximum1 = answer1[A-1];
  ll maximum2 = answer1[A-2];
  for(i=0;i<A;i++)
  {
   if(answer2[i]==maximum1){cout<<maximum2<<endl;}
   else{cout<<maximum1<<endl;}
  }
  return 0;
}


Measured memory_bytes: 4736
N = int(input())
D = sorted(list(map(int, input().split())))
M = int(input())
T = sorted(list(map(int, input().split())))
C = {}
for d in D:
    if d in C:
        C[d] += 1
    else:
        C[d] = 1
E = {}
for t in T:
    if t in E:
        E[t] += 1
    else:
        E[t] = 1
for key, val in E.items():
    if key in C:
        C[key] //= val

print('YES' if min([C[t] if t in C else 0 for t in T]) > 0 else 'NO')


Measured memory_bytes: 123348
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c==' '||c=='\n')c=_buff.get();return c;}
int n,m,cnt[100111];
bool has[100111];
int main()
{
	getii(n,m);
	for(int i=1;i<=n;i++)cnt[i]=1;
	has[1]=1;
	for(int i=1;i<=m;i++)
	{
		int x,y;
		getii(x,y);
		has[y]|=has[x];
		cnt[x]--;
		cnt[y]++;
		if(!cnt[x])has[x]=0;
	}
	int ans=0;
	for(int i=1;i<=n;i++)ans+=has[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

// Fills Z array for given string str[]
void getZarr(string str, vector<int> &Z)
{
    int n = str.length();
    int L, R, k;

    // [L,R] make a window which matches with prefix of s
    L = R = 0;
    for (int i = 1; i < n; ++i)
    {
        // if i>R nothing matches so we will calculate.
        // Z[i] using naive way.
        if (i > R)
        {
            L = R = i;

            // R-L = 0 in starting, so it will start
            // checking from 0'th index. For example,
            // for "ababab" and i = 1, the value of R
            // remains 0 and Z[i] becomes 0. For string
            // "aaaaaa" and i = 1, Z[i] and R become 5
            while (R<n && str[R-L] == str[R])
                R++;
            Z[i] = R-L;
            R--;
        }
        else
        {
            // k = i-L so k corresponds to number which
            // matches in [L,R] interval.
            k = i-L;

            // if Z[k] is less than remaining interval
            // then Z[i] will be equal to Z[k].
            // For example, str = "ababab", i = 3, R = 5
            // and L = 2
            if (Z[k] < R-i+1)
                Z[i] = Z[k];

            // For example str = "aaaaaa" and i = 2, R is 5,
            // L is 0
            else
            {
                // else start from R and check manually
                L = i;
                while (R<n && str[R-L] == str[R])
                    R++;
                Z[i] = R-L;
                R--;
            }
        }
    }
}

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

	int ans = 0;
	for(int i=0; i<N; i++){
		vector<int> z(N-i);
		getZarr(S.substr(i), z);
		debug(z);
		for(int j=1; j<N-i; j++){
			int x = min(j, z[j]);
			ans = max(ans, x);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int x,y,a,r;
    scanf("%d %d",&x ,&y);
    if(x < y){
        a=x;
        x=y;
        y=a;
    }
    r = x % y;
  while(r!=0){
    x = y;
    y= r;
    r = x % y;
  }
    printf("%d\n",y);
    return 0;
}


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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  int a[n], b[m];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> b[i];
  }
  sort(a, a + n);
  sort(b, b + m);
  for (int i = a[n - 1] + 1; i <= b[0]; i++) {
    if (x < i && i <= y) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((b * 10 + c) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
def solve():
    p = read()
    result = think(p)
    write(result)


def read():
    n = read_int(1)[0]
    return read_float(n)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(p):
    n = len(p)

    # dp[ith coin frip trial][faces count] = prob
    # dp[ith][facecount] = dp[ith - 1][facecount - 1] * Phead + dp[ith - 1][facecount] * Ptail

    accumulated = [[0.0 for x in range(n + 1)] for y in range(n)]
    accumulated[0][0] = 1.0 - p[0]
    accumulated[0][1] = p[0]

    for ith, each_p in enumerate(p):
        if ith == 0:
            continue
        for face_count in range(ith + 2):
            if face_count == 0:
                accumulated[ith][face_count] = accumulated[ith - 1][face_count] * (1.0 - each_p)
            elif face_count == ith + 1:
                accumulated[ith][face_count] = accumulated[ith - 1][face_count - 1] * each_p
            else:
                accumulated[ith][face_count] = accumulated[ith - 1][face_count] * (1.0 - each_p) + accumulated[ith - 1][face_count - 1] * each_p

    return sum(accumulated[n - 1][((n + 1) // 2):])


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 120156
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repx(i,a,b,x) for(ll i=a;i<b;i+=x)
#define rev(i,a,b) for(ll i=a;i>b;i--)
#define revx(i,a,b,x) for(ll i=a;i>b;i-=x)
#define arep(it,v) for(auto it=v.begin();it!=v.end();it++)
#define wh1(n) rep(xy1,0,n)
#define wh2(n) rep(xy2,0,n)
#define wh3(n) rep(xy3,0,n)
#define sc(i) cin>>i
#define ssc(i,j) sc(i);sc(j)
#define sssc(i,j,k) ssc(i,j);sc(k)
#define pf(i) cout<<i<<" "
#define pfn(i) cout<<i<<endl
#define cvec(v,n) rep(abc,0,n){ll xyz;sc(xyz);v.pb(xyz);}
#define pvec(v,n) rep(abc,0,n){pf(v[abc].F);pf(v[abc].S);}pfn("")
#define pll pair<ll,ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define sll set<ll>
#define spll set<pll>
#define vpll vector<pll>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define pq(a) priority_queue<a>
#define pqc(a,cmp) priority_queue<a,vector<a>,cmp>
#define F first
#define S second
#define B begin
#define E end
#define R return
#define mp make_pair
#define pb push_back
#define ln length()
#define to_s to_string
#define Sort(v) sort(v.begin(),v.end())
#define Scmp(v,cmp) sort(v.begin(),v.end(),cmp)
#define zero_arr(v) memset(v,0,sizeof(v))
#define update_map(m,i) if(m.find(i)!=m.end()){m[i]++;}else{m[i]=1;}
#define update_mapx(m,i,x) if(m.find(i)!=m.end()){m[i]+=x;}else{m[i]=x;}
#define M 1000000007
#define INF 2000000000
#define fast ios::sync_with_stdio(0); cin.tie(0)
int main(){
    fast;
    ll n;
    sc(n);
    vll v;
    cvec(v,n);
    vll c(9,0);
    rep(i,0,n){
        if(v[i]<400){
            c[0]++;
        }else if(v[i]<800){
            c[1]++;
        }else if(v[i]<1200){
            c[2]++;
        }else if(v[i]<1600){
            c[3]++;
        }else if(v[i]<2000){
            c[4]++;
        }else if(v[i]<2400){
            c[5]++;
        }else if(v[i]<2800){
            c[6]++;
        }else if(v[i]<3200){
            c[7]++;
        }else{
            c[8]++;
        }
    }
    ll c1=0,c2=0;
    rep(i,0,8){
        if(c[i]>0){
            c1++;
        }
    }
    c2=c[8];
    pf(max(c1,1LL));
    pfn(c1+c2);
    R 0;
}

Measured memory_bytes: 256
//
// Created by Yoshiki Shino on 2018/07/29.
//

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    string all_food;
    cin >> all_food;

    int takahashi_brain = 0;
    for (char food:all_food) {
        if (food == '+') {
            takahashi_brain++;
        } else if (food == '-') {
            takahashi_brain--;
        } else {
            cout << "不正な文字です" << endl;
        }
    }

    cout << takahashi_brain << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;

int main(){
	int a, b;
    cin >> a >> b;
    if(a <= 9 && b <= 9){
        cout << a*b << endl;
    }
    else{
        cout << "-1" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def get_input() -> str:
    """
    標準入力を取得する.

    Returns:\n
        str: 標準入力
    """
    S = input()

    return S


def main(S: str) -> None:
    """
    メイン処理.

    Args:\n
        S (str): 長さ1以上10以下の英大文字列
    """
    # 求解処理
    N = len(S)
    ans = 0
    for i in range(N):
        for j in range(i, N):
            if all("ACGT".count(c) == 1 for c in S[i: j + 1]):
                ans = max(ans, j - i + 1)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    S = get_input()

    # メイン処理
    main(S)


Measured memory_bytes: 9060
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
s = [0] * 4
for i in range(n):
	s[0] += abs(x[i] - y[i])
	s[1] += abs(x[i] - y[i])**2
	s[2] += abs(x[i] - y[i])**3
	s[3] = max(s[3], abs(x[i] - y[i]))
s[1] = s[1]**(1/2)
s[2] = s[2]**(1/3)
for i in range(4):
	print('%f' % s[i])




Measured memory_bytes: 5644
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n, x; readV(n, x);
  int[] m; readC(n, m);

  x -= m.sum;
  writeln(n + x/m.reduce!min);
}


Measured memory_bytes: 256
n=int(input())
a=[]
if n==0:
    print("0")
else:
    while n!=0:
        r=n%(-2)
        n=n//(-2)
        if r<0:
            r+=(2)
            n+=1
        a.append(r)
a=a[::-1]
print(*a,sep='')

Measured memory_bytes: 3060
#include<cstdio>
int main(){
    while(true){
        char val[1000];
        scanf("%s",val);
        int sum=0,i=0;
        while(val[i]){
            sum+=val[i]-'0';
            i++;
        }
        if(sum==0)break;
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 2596
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>
#include <chrono>

using namespace std;
using ll = long long;

int main() {
	int N, T;
	cin >> N >> T;
	int a = 9999;
	for (int i = 0; i != N; ++i) {
		int c, t;
		cin >> c >> t;
		if (t <= T) {
			a = min(a, c);
		}
	}
	if (a == 9999) {
		cout << "TLE" << endl;
	}
	else {
		cout << a << endl;
	}
	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MAXN = 1e5+ 9;
#define INF 0x3f3f3f3f
vi g[MAXN];
int n, cnt, grau[MAXN];
pii edge[MAXN];
map<pii, int> mp;

void dfs(int u, int color, int p){
    bool first = p == u;
    int c = 1;
    trav(a, g[u]){
        if (a != p){
            if (c == color && color != INF){
                c = color + 1;
                mp[make_pair(a, u)] = mp[make_pair(u, a)] = c;
                dfs(a, c, u);
                c++;
            }
            else{
                dfs(a, c, u);
                mp[make_pair(a, u)] = mp[make_pair(u, a)] = c;
                c++;
            }
        }
    }
}

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    
    cin >> n;
    rep(i, 0, n - 1){
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[i].first = a; edge[i].second = b;
        g[a].push_back(b);
        g[b].push_back(a);
        grau[a]++, grau[b]++;
    }
    cnt = *max_element(grau, grau+n);
    //rep(i, 0, n)
      //  cnt = max(cnt, grau[i]);
    dfs(0, INF, 0);
    cout << cnt << '\n';
    rep(i, 0, n-1){
        cout << mp[edge[i]] << '\n';
    }
    return 0;
}
/**/

Measured memory_bytes: 21632
#include <iostream>
#include <stdio.h>

using namespace std;
typedef long long int lint;

void answer()
{
	int H, W;
	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cout << (((i + j) % 2 == 0) ? '#' : '.');
			}
			cout << endl;
		}
		cout << endl;
	}
}

int main()
{
	answer();
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;
using ull=unsigned long long int;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;

    ll t = c - a - b;
    if (t < 0) {
        cout << "No" << endl;
        return 0;
    }

    if (4*a*b < t*t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main () {
  int n,cnt = 0,cnt1 = 0;
  cin >> n;
  for (int i = 1; i <= n; i++){
    cnt = 0;
    for (int j = 1; j <= i; j++){
      if (i % j == 0 && i % 2 == 1){
        cnt++;
      }
    }
    if (cnt == 8){
      cnt1++;
    }
  }
  cout << cnt1 << '\n';
  return 0;
}

Measured memory_bytes: 3612
import scala.io.Source.stdin
 
object Main extends App {
  stdin.getLines.map(_.toDouble).foreach { x =>
    println {
      x match  {
        case i if i <= 48D => "light fly"
        case i if i <= 51D => "fly"
        case i if i <= 54D => "bantam"
        case i if i <= 57D => "feather"
        case i if i <= 60D => "light"
        case i if i <= 64D => "light welter"
        case i if i <= 69D => "welter"
        case i if i <= 75D => "light middle"
        case i if i <= 81D => "middle"
        case i if i <= 91D => "light heavy"
        case _ => "heavy"
      }
    }
  }
}

Measured memory_bytes: 43588
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>


using namespace std;


int main(){

	int N;
	int ans = 0;

	cin >> N;

	int p = 0;
	for(int i = 0; i < N ;i++){
		int a;
		cin >> a;
		if(p < a) ans += a-p;
		p = a;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384