akhauriyash/Code-Regression huggingface dataset:
#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;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long DP[10001*100];
long DP2[10001*100];
void Calc(){
	string S = res();
	int D = rei();
	DP2[0] = 1;
	for(int i=0;i<S.length();i++){
		int p = S[i] - '0';
		for(int j=0;j<D;j++){
			for(int k=0;k<p;k++){
				DP[(i+1)*100 + (j+k) % D] += DP[i*100 + j] + DP2[i*100 + j];
			}
			DP[(i+1)*100 + (j+p) % D] += DP[i*100 + j];
			DP2[(i+1)*100 + (j+p) % D] += DP2[i*100 + j];
			for(int k=p+1;k<10;k++){
				DP[(i+1)*100 + (j+k) % D] += DP[i*100 + j];
			}
		}
		for(int j=0;j<D;j++){
			DP[(i+1)*100 + j] %= mod;
			DP2[(i+1)*100 + j] %= mod;
		}
	}
	long ans = DP[S.length()*100] + DP2[S.length()*100] + mod - 1;
	cout << ans % mod << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
int c[3][3];

int main()
{
  for(int i = 0; i < 3; i++)
    for(int j = 0; j < 3; j++)
      cin >> c[i][j];
  
  // Check b values
  for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
      vector<int> check;
      for(int k = 0; k < 3; k++)
        check.push_back(c[k][i]-c[k][j]);
      size_t cnt = std::count(check.begin(), check.end(), check[0]);
      if(cnt != 3) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  // Check a values
  for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
      vector<int> check;
      for(int k = 0; k < 3; k++)
        check.push_back(c[i][k]-c[j][k]);
      size_t cnt = std::count(check.begin(), check.end(), check[0]);
      if(cnt != 3) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
# input = sys.stdin.readline

def main():
  n = int(input())
  hlist = list(map(int, input().split()))
  for i in range(n-2, -1, -1):
    if hlist[i+1] < hlist[i]:
      hlist[i] -= 1
  for prevh, h in zip(hlist, hlist[1:]):
    if prevh > h:
      print('No')
      sys.exit(0)
  print('Yes')


if __name__ == '__main__':
  main()


Measured memory_bytes: 14396
def gcdf(a):
    a.sort()
    a0=a[0]
    a=[int(x%a0) for x in a if x%a0 != 0]
    if len(a)==0:
        return a0
    else:
        a.append(a0)
        a0=min(a)
        return gcdf(a) 

n=int(input())
a=list(map(int,input().split()))

if n==2:
    print(max(a))
elif n<2**8:
    gcdv=0
    for i in range(n):
        acpy=list(a)
        del acpy[i]
        gcdx=gcdf(acpy)
        if gcdx>gcdv:
            gcdv=gcdx
    print(gcdv)
else:
    m=int(n/100)
    ns=int(n/m)
    rgcd=[]
    for mi in range(m):
        ms=ns*mi
        if mi==m-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
        gcdm=gcdf(am)
        rgcd.append(gcdm)
    gcdv=0

    for mi in range(m):
        rgcd1=list(rgcd)
        del rgcd1[mi]
        gcdrg1=gcdf(rgcd1)
        ms=ns*mi
        if mi==m-1:
            am=a[ms:n]
        else:
            am=a[ms:ms+ns]
#        print(mi,gcdf(am),len(am),gcdf(rgcd1))
        for i in range(len(am)):
            acpy=list(am)
#            del acpy[i]
#            acpy.append(gcdrg1)
            acpy[i]=gcdrg1
            gcdx=gcdf(acpy)
            if gcdx>gcdv:
                gcdv=gcdx
    print(gcdv)


Measured memory_bytes: 14204
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <string>
#include <cmath>
#include <map>
#include <vector>
#include <sstream>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;
typedef long long ll;


void kai(string z[], int hk){
	string w[8];
	fill(w,w+8,"        ");
	if(hk==1)
		rep(i,8) rep(j,8) w[j][7-i]=z[i][j];
	else if(hk==2)
		rep(i,8) rep(j,8) w[7-i][7-j]=z[i][j];
	else
		rep(i,8) rep(j,8) w[7-j][i]=z[i][j];
	rep(i,8) cout << w[i] << endl;
}

int main() {
	string ba[8];
	
	rep(i,8) cin >> ba[i];
	cout << "90" << endl;
	kai(ba,1);
	cout << "180" << endl;
	kai(ba,2);
	cout << "270" << endl;
	kai(ba,3);
	
	return 0;
}

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

import static java.lang.System.in;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] D = new int[n];
        for(int i=0;i<n;i++) D[i]=sc.nextInt();
        int ans = help(D);
        System.out.println(ans);

    }
    static int help(int[] D){
        Arrays.sort(D);
        if(D[0]==0) return 0;
        int[] rec = new int[13];
        for(int i=0;i<D.length;i++){
            int cur = D[i];
            rec[cur]++;
            if(rec[cur]>2) return 0;
        }
        if(rec[12]>1) return 0;
        ArrayList<Integer> done = new ArrayList<>(), undone = new ArrayList<>();
        for(int i=1;i<12;i++){
            if(rec[i]==0) continue;
            if(rec[i]==2){
                done.add(i);
                done.add(24-i);
            }
            else undone.add(i);
        }
        if(rec[12]==1) done.add(12);
        if(undone.size()==0) return minGap(done);
        int len = undone.size();
        int ans = 0;
        for(int state=0;state<(1<<len);state++){
            for(int i=0;i<len;i++){
                if((state&(1<<i))==0) done.add(undone.get(i));
                else done.add(24-undone.get(i));
            }
            ans = Math.max(ans,minGap(done));
            for(int i=0;i<len;i++) done.remove(done.size()-1);
        }
        return ans;
    }
    static int minGap(ArrayList<Integer> time){
        int ans = 50;
        for(int w:time) ans = Math.min(ans,Math.min(w,24-w));
        for(int i=0;i<time.size();i++){
            for(int j=i+1;j<time.size();j++){
                int cur = Math.abs(time.get(i)-time.get(j));
                ans = Math.min(ans,Math.min(cur,24-cur));
            }
        }
        return ans;
    }
}


Measured memory_bytes: 24020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1000000007;
struct node
{
	int a[26];	
};
int n;
const int N=500005;
node tree[2*N];
void modify(int p,int val,int c){
	p=p+n;
	tree[p].a[c]=val;
	p=p/2;
	for(int i=p;i>0;i=i/2){
		for(int j=0;j<26;j++){
    			tree[i].a[j]=tree[2*i].a[j]+tree[2*i+1].a[j];
    	}
	}
}
int query(int k,int l, int r) {  // sum on interval [l, r)
  int res = 0;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l&1) res += tree[l++].a[k];
    if (r&1) res += tree[--r].a[k];
  }
  return res;
}
int main() {
   
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
    	cin>>n;
    	string s;cin>>s;
    	int q;cin>>q;
    	memset(tree,0,sizeof(tree));
    	rep(i,n){
    		int c=s[i]-'a';
    		tree[n+i].a[c]=1;
    	}
    	for(int i=n-1;i>0;i--){
    		for(int j=0;j<26;j++){
    			tree[i].a[j]=tree[2*i].a[j]+tree[2*i+1].a[j];
    		}
    	}
    	while(q--){
    		int t;cin>>t;
    		if(t==1){
    			int k;cin>>k;char c;cin>>c;k--;
    			modify(k,0,s[k]-'a');
    			modify(k,1,c-'a');
    			s[k]=c;
    		}
    		else{
    			int l,r;cin>>l>>r;l--;
    			int ans=0;
    			for(int i=0;i<26;i++){
    				int y=query(i,l,r);
    				if(y>0)y=1;
    				ans=ans+y;
    			}
    			cout<<ans<<endl;
    		}
    	}
    } 	
    return 0;   
}	

Measured memory_bytes: 102556
a,b,c,d= input().split()
x1,y1,x2,y2=(int(a),int(b),int(c), int(d))
x_dif = x2-x1
y_dif = y2-y1
x_d = abs(x_dif)
y_d=abs(y_dif)
w = x1
z =y2
y =x2
x = y1
if x_dif == 0:
    if y_dif > 0:
        print(x2-abs(y_dif),z,y-abs(y_dif),x)
    else:
        print(x2+abs(y_dif),z,y+abs(y_dif),x)
elif y_dif ==0:
    if x_dif > 0:
        print(x2,y2+abs(x_dif),w,z+abs(x_dif))
    else:
        print(x2,y2-abs(x_dif),w,z-abs(x_dif))
elif x_dif >0 and y_dif >0:
    print(x2- y_d, y2 + x_d, x1-y_d,y1+x_d)
elif x_dif >0 and y_dif <0:
    print(x2+ y_d, y2 + x_d, x1+y_d,y1+x_d)
elif  x_dif <0 and y_dif <0:
    print(x2+y_d, y2 - x_d, x1+y_d,y1-x_d)
elif  x_dif <0 and y_dif >0:
    print(x2- y_d, y2 - x_d, x1-y_d, y1-x_d)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int k = Integer.parseInt(sc.next());
		
		int x = Integer.parseInt(sc.next());
		
		int ans = 500 * k;
		
		if(ans >= x) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 23124
R,G,B,N = (gets).split(" ").map { |i| i.to_i }

count = 0

N.div(R).downto(0) do |r|
  (N-R*r).div(G).downto(0) do |g|
    b,m = (N-(R*r+G*g)).divmod(B)
    if (b >= 0) && (m == 0) then
        #puts "(#{r}, #{g}, #{b})"
        count += 1
    end
  end
end

puts count


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

int main() {
  int H,W;
  cin >> H >> W;

  for (int k=0; k<W+2; k++) {
    cout << "#";
  }
  cout << endl;

  for (int i=0; i<H; i++) {
    string str;
    cin >> str;
    cout << "#" << str << "#" << endl;
  }

  for (int k=0; k<W+2; k++) {
    cout << "#";
  }
  cout << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll f(ll x,ll c,ll d){
    ll res =x;
    res -=x/c;
    res -=x/d;
    res+= x/lcm(c,d);
    return res;
}

int main(){
    ll n;
    cin>>n;
    ll cnt=0;
    ll a;
    vector<ll>v(n);
    rep(i,n){
        cin>>a;
        if(a<0){cnt++;
        v[i]-=a;
        }else v[i]=a;
    }
    sort(v.begin(),v.end());
    
    ll sum=0;
    rep(i,n){
          sum+=v[i];
          }
    if(cnt%2==0){
        cout<<sum<<endl;
        return 0;
    }else{
        sum-=(v[0]*2);
        cout<<sum<<endl;
        return 0;
    }

}


Measured memory_bytes: 4016
A, B = map(int, input().split())
a = A % 2
b = B % 2

diff = B - A + 1

if a == 0 and b == 0:
    diff -= 1
    ans = 1 ^ B if diff % 4 == 2 else B    
elif a == 0 and b == 1:
    ans = 1 if diff % 4 == 2 else 0
elif a == 1 and b == 0:
    diff -= 2
    ans = A ^ 1 ^ B if diff % 4 == 2 else A ^ B
else:
    diff -= 1
    ans = A ^ 1 if diff % 4 == 2 else A
print(ans)


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

bool v[101];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int x,n;
    cin>>x>>n;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        v[k]=1;
    }
    int up,down;
    for(int i=x;i<=100;i++){
        if(v[i]==0){
            up=i;
            break;
        }
        if(i==100)
            up=101;
    }
    for(int i=x;i>=0;i--){
        if(v[i]==0){
            down=i;
            break;
        }
        if(i==0)
            down=-1;
    }
    if(n==0)
        cout<<x<<endl;
    else{
        if(up-x<x-down){
            cout<<up<<endl;
        }
        else{
            cout<<down<<endl;
        }
    }
    return 0;
}


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

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	pair<int, int> h1, h2;
	int k;
	cin >> h1.first >> h1.second >> h2.first >> h2.second >> k;

	h1.first *= 60;
	h2.first *= 60;

	int ans = (h2.first+h2.second) - (h1.first + h1.second);

	ans = ans - k;

	cout << ans << endl;

	return 0;
}

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

int main() {
  string a, b;
  cin >> a >> b;
  int dp[1001][1001] = {{0}};

  for (int i = 0; i < a.size(); i++)
  {
    dp[i+1][0] = i+1;
  }
  for (int j = 0; j < b.size(); j++)
  {
    dp[0][j+1] = j+1;
  }
  

  for (int i = 0; i < a.size(); i++)
  {
    for (int j = 0; j < b.size(); j++)
    {
      int c = 1;
      if (a[i]==b[j])
      {
        c = 0;
      }
      
      dp[i+1][j+1] = min(dp[i][j+1]+1, min(dp[i+1][j]+1, dp[i][j]+c));
    }
  }
  cout << dp[a.size()][b.size()] << endl;

}


Measured memory_bytes: 7132
#include <bits/stdc++.h>
#define ll         long long int 
#define pb         push_back
#define umap       unordered_map
#define mod        1000000007
#define all(x)     (x).begin(), (x).end()
#define rall(x)    (x).rbegin(), (x).rend()
#define MN(a,b,c)  min(a,min(b,c))
#define MX(a,b,c)  max(a,max(b,c))
#define pr1         pair<ll,ll>
#define F          first
#define S          second
#define mP         make_pair
#define f(i,n)     for(int i=0;i<n;i++)
#define f1(i,x,y)  for(int i=x;i<=y;i++)
#define f2(i,x,y)  for(int i=x;i>=y;i--)
#define yes        cout<<"Yes"<<"\n"
#define no         cout<<"No"<<"\n"
#define modsum(a,b)  ((a%mod)+(b%mod))%mod
#define modpro(a,b)  ((a%mod)*(b%mod))%mod
//__builtin_popcount(x)
//__builtin_parity(x)   =(number of set bits)%2
//__builtin_clz(x)      to count the number of leading  zeroes 
//__builtin_ctz(x)      to count the number of trailing zeroes 
//__gcd(a,b)
using namespace std;
ll modularExponentiation(ll x,ll n,ll M)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=((result%M) *(x%M))%M;
        x=((x%M)*(x%M))%M;
        n=n/2;
    }
    return result;
}
ll binaryExponentiation(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=result * x;
        x=x*x;
        n=n/2;
        if(result<0)return result;
    }
    return result;
}
ll pow1(ll x,ll y)
{
    ll z=1;
    while(y--){z=z*x;}
    return z;
}
int main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 ll a,b,c,d;
 cin>>a>>b>>c>>d;
 if(a>=0 && c>=0)
    cout<<b*d;
 else if(a<0 && c>=0)
    {
        if(b>=0) cout<<b*d;
        else     cout<<b*c;
    }
 else if(a>=0 && c<0)
    {
       if(d>=0) cout<<d*b;
       else     cout<<d*a;
    }
 else
    {
        if(b>=0 && d>=0)
            cout<<max(a*c,b*d);
        else if(b<0 && d>=0)
            cout<<a*c;
        else if(b>=0 && d<0)
            cout<<a*c;
        else 
            cout<<a*c;
    }
}


  

Measured memory_bytes: 3656
#include <iostream>
int main() {
  int n,m,x;
  std::cin >> n >> m >> x;
  int p = 0, q = 0;
  for (int i = 0; i < m; i++) {
    int a;
    std::cin >> a;
    if (a < x) p++;
    else q++;
  }
  std::cout << std::min(p,q) << std::endl;
  return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
const long long mod=1000000007;
using namespace std;
int main()
{
    int n,i,j,k;
    cin>>n>>k;
    vector<int>arr(n+1);
    for(i=1;i<=n;i++) cin>>arr[i];
    vector<long long>dp(k+1);
    vector<long long>pre(k+1);
    dp[0]=1,pre[0]=1;
    for(j=1;j<=k;j++) dp[j]=0l,pre[j]=1l;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=k;j++)
        {
            if(j-arr[i]-1<0) dp[j]=pre[j];
            else dp[j]=(pre[j]-pre[j-arr[i]-1]+mod)%mod;
        }
        for(j=1;j<=k;j++)
         pre[j]=(pre[j-1]+dp[j])%mod;
    }
    cout<<dp[k];
}


Measured memory_bytes: 1792
N=int(input())
D=list(map(int,input().split()))
dp=[0]
x,r=0,1
m=998244353
if D[0]!=0:
    r=0
D.sort()
for d in D:
    if d==x:
        dp[x]+=1
    elif d==x+1:
        dp.append(1)
        x+=1
    else:
        r=0
    r=(r*dp[x-1])%m
print(r%m if dp[0]==1 else 0)

Measured memory_bytes: 14396
#include<stdio.h>
#include<string.h>
char s[200],tgt[200];
int main(void){
    int i,j,len;
    char tail;
    for(i=0;i<200;i++){
        s[i]=0;
        tgt[i]=0;
    }
    scanf("%s",s);
    scanf("%s",tgt);
    if(strcmp(s,tgt)==0){
        printf("Yes\n");
        return 0;
    }
    len=strlen(s);
    for(i=0;i<len;i++){
        tail=s[len-1];
        for(j=len-1;j!=0;j--){
            s[j]=s[j-1];
        }
        s[0]=tail;
        if(strcmp(s,tgt)==0){
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    set<int> S;
    set<int> T;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        S.insert(a);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int a;
        cin >> a;
        T.insert(a);
    }
    set<int> result;
    set_intersection(S.begin(), S.end(), T.begin(), T.end(),
                     inserter(result, result.end()));
    cout << result.size() << endl;
    return 0;
}

Measured memory_bytes: 10120
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
 
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a+b==c) puts("Yes");
    else if(b+c==a) puts("Yes");
    else if(c+a==b) puts("Yes"); 
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int need[10] = {10000, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	int n, m;
	cin >> n >> m;
	vector<int> in(m);
	for (int i = 0; i < m; i++) {
		cin >> in[i];
	}
	vector<string> dp(n + 100);
	auto chmax = [&] (string &s, string t) {
		int sn = (int) s.length();
		int tn = (int) t.length();
		if (sn != tn) s = (sn < tn ? t : s);
		else {
			for (int i = 0; i < sn; i++) {
				if (s[i] > t[i]) break;
				if (s[i] < t[i]) {
					s = t;
					break;
				}
			}
		}
		return;
	};
	dp[0] = "";
	for (int i = 0; i <= n; i++) {
		if (i && dp[i] == "") continue;
		for (int j = 0; j < m; j++) {
			chmax(dp[i + need[in[j]]], dp[i] + (char) (in[j] + '0'));
		}
	}
	cout << dp[n] << endl;
	return 0;	
}

Measured memory_bytes: 37632
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		out.println((ir.nextInt() - 2) * 180);
	}

	public static void main(String[] args) {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}

	static void tr(Object... o) {
		out.println(Arrays.deepToString(o));
	}
}


Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=1e5+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
}
int n;
ll dp[N][3];
const ll inf=1e18;
void work()
{	
	n=read<int>();
	For(i,1,n)For(j,0,2)dp[i][j]=-inf;
	char s[5];
	int x;
	x=read<int>();
	dp[1][0]=x;
	int ty;
	For(i,2,n)
	{
		scanf("%s",s);
		x=read<int>();
		ty=(s[0]=='+'?1:-1);
		
		cmax(dp[i][0],dp[i-1][0]+x*ty);
		cmax(dp[i][0],dp[i-1][1]+x*ty);
		cmax(dp[i][0],dp[i-1][2]+x*ty);
		
		cmax(dp[i][1],dp[i-1][1]+x*ty*(-1));
		cmax(dp[i][1],dp[i-1][2]+x*ty*(-1));
		if(s[0]=='-')
		{
			cmax(dp[i][1],dp[i-1][0]-x);
			cmax(dp[i][1],dp[i-1][1]-x);
			cmax(dp[i][1],dp[i-1][2]-x);
		}
		cmax(dp[i][2],dp[i-1][2]+x*ty);
		if(s[0]=='-')
		{
			cmax(dp[i][2],dp[i-1][1]+x);
			cmax(dp[i][2],dp[i-1][2]+x*ty*(-1));
		}
		//cout<<dp[i][0]<<' '<<dp[i][1]<<' '<<dp[i][2]<<endl;
	}
	write(max(max(dp[n][0],dp[n][1]),dp[n][2]),'\n');
}
int main()
{

	work();
	return 0;
}



Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n;
cin >> n;
switch(n%10)
{
case  2:
case 4:
case 5:
case 7:
case 9: cout << "hon";
break;
case  0:
case 1:
case 6:
case 8: cout << "pon";
break;
case 3: cout << "bon";
}
return 0;
}

Measured memory_bytes: 3580
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>	
#include <time.h>
#include <vector>
#include <stdio.h>
#include <memory.h>
#include <string>
#include <string.h>
#include <map>
#include <algorithm>
#include <queue>
#include <set>
#include <time.h>
#include <assert.h>
#include <sstream>
//#include <unordered_map>
#include <bitset>
#include <utility>
#include <iomanip>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <math.h>
#include <cmath>
#include <complex>
using namespace std;
typedef long long ll;
typedef complex<double> point;

int x, y;


int main() {

	scanf("%d%d", &x, &y);
	if(x%y == 0)
		return 0 * puts("-1");
	printf("%d\n", x);


	return 0;
}

Measured memory_bytes: 256
from sys import exit, stdin
N = int(stdin.readline().rstrip())
B = [int(_) for _ in stdin.readline().rstrip().split()]
def solve():
    ans = []
    for _ in range(N):
        pivot = -1
        for j in range(len(B)-1, -1, -1):
            if B[j] == j+1:
                pivot = j
                break
        if pivot == -1:
            print(-1)
            exit()
        ans.append(pivot+1)
        B.pop(0+pivot)
    ans.reverse() 
    for v in ans:
        print(v)
solve()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int f(int n){
    if(n==0) return 1;
    else return n*f(n-1);
}

int main(void){
    int n;
    cin >> n;
    int x[n],y[n];
    REP(i,n) cin >> x[i] >> y[i];
    vector<int> v(n);
    iota(ALL(v),0);
    long double sum=0;
    do{
        for(int i=0;i<n-1;i++){
            sum+=sqrt((x[v[i]]-x[v[i+1]])*(x[v[i]]-x[v[i+1]]) + (y[v[i]]-y[v[i+1]])*(y[v[i]]-y[v[i+1]]));
        }
    }while(next_permutation(ALL(v)));
    printf("%.7Lf\n",sum/f(n));
    return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    int p[N], ans = 0;
    rep(i, N) cin >> p[i];
    sort(p, p + N);
    rep(i, K) {
        ans += p[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun May 10 18:07:31 JST 2020
 **/

signed main() {
    Int Q;
    std::cin >> Q;
    std::list<int> li;
    auto it = li.begin();
    REP(q, Q) {
        Int t;
        std::cin >> t;
        if (t == 0) {
            Int x;
            std::cin >> x;
            // insert x
            it = li.insert(it, x);
        } else if (t == 1) {
            Int d;
            std::cin >> d;
            // move d
            it = std::next(it, d);
        } else if (t == 2) {
            // erase
            it = li.erase(it);
        } else {
            assert(false);
        }
    }
    for (int x : li) std::cout << x << "\n";
}



Measured memory_bytes: 18680
from collections import deque

S = input()


s1 = deque()
s2 = deque()
total = 0

for i, s in enumerate(S):
    if s == '\\':
        s1.append(i)
    elif s == '/':
        if not s1:
            continue
        j = s1.pop()
        total += i - j

        vol = i - j
        while s2 and s2[-1][0] >= j:
            vol += s2.pop()[1]

        s2.append((j, vol))

print(total)
print(len(s2), *[vol for idx, vol in s2])



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


void solve(long long a, long long b, long long h){
    cout << (a+b)*h/2 << endl;
}

int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long h;
    scanf("%lld",&h);
    solve(a, b, h);
    return 0;
}


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

int main() {
  int N;
  int count=1;
  cin >> N;
  vector<string>S(N);
  for(int i=0; i<N; i++)
    cin >> S.at(i);
  sort(S.begin(), S.end());
  for(int i=0; i<N-1; i++){
    if(S.at(i)!=S.at(i+1))
      count++;
  }
  cout << count;
}
  

Measured memory_bytes: 9504
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val a = readLine()!!.split(' ').map { it.toInt() }

    var sum = 0.0
    repeat(n) {
        sum += a[it]
    }
    val border = sum/(4 * m)

    var oknum = 0
    repeat(n) {
        if(a[it] >= border) oknum++
    }

    if(oknum >= m) println("Yes")
    else println("No")
}


Measured memory_bytes: 38124
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, d; cin >> a >> b >> c >> d;
  if((abs(a - b) <= d && abs(b-c) <= d) || abs(a-c) <= d){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y, h;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++)
		sum *= (x--);
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int h, w;
bool a[50][50];
int b[50][50];
signed main() {
	cin >> h >> w;
	int sum = 0;
	for (int i = 0; i < h; i++) {
		string u;
		cin >> u;
		for (int j = 0; j < w; j++) {
			if (u[j] == '#') {
				a[i][j] = 0;
				sum++;
			}
			else 
				a[i][j] = 1;
			b[i][j] = inf;
		}
	}
	queue<H>q;
	q.push(H{ 0,0 });
	b[0][0] = 0;
	while (!q.empty()) {
		H t = q.front(); q.pop();
		if (t.x > 0 && a[t.x - 1][t.y]) {
			if (b[t.x - 1][t.y] > b[t.x][t.y] + 1) {
				b[t.x - 1][t.y] = b[t.x][t.y] + 1;
				q.push(H{ t.x - 1,t.y });
			}
		}
		if (t.x < h - 1 && a[t.x + 1][t.y]) {
			if (b[t.x + 1][t.y] > b[t.x][t.y] + 1) {
				b[t.x + 1][t.y] = b[t.x][t.y] + 1;
				q.push(H{ t.x + 1,t.y });
			}
		}
		if (t.y > 0 && a[t.x][t.y - 1]) {
			if (b[t.x][t.y - 1] > b[t.x][t.y] + 1) {
				b[t.x][t.y - 1] = b[t.x][t.y] + 1;
				q.push(H{ t.x,t.y - 1 });
			}
		}
		if (t.y < w - 1 && a[t.x][t.y + 1]) {
			if (b[t.x][t.y + 1] > b[t.x][t.y] + 1) {
				b[t.x][t.y + 1] = b[t.x][t.y] + 1;
				q.push(H{ t.x,t.y + 1 });
			}
		}
	}
	if (b[h - 1][w - 1] == inf) {
		cout << -1 << endl;
		return 0;
	}
	cout << h*w - b[h - 1][w - 1] - sum - 1 << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l=[[] for i in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  l[a].append(b)
  l[b].append(a)
lans=[]
def dfs(i,l1):
  if len(l1)==n:
    lans.append(l1)
    return
  for j in l[i]:
    if j in l1:
      pass
    else:
      l2=l1+[j]
      dfs(j,l2)
  return
dfs(1,[1])
print(len(lans))

Measured memory_bytes: 3700
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final long x = sc.nextLong();
		
		long[] array = new long[N];
		for(int i = 0; i < N; i++){
			array[i] = sc.nextLong();
		}
		
		long answer = 0;
		for(int i = 1; i < N; i++){
			final long value = array[i - 1] + array[i];
			
			//System.out.println(array[i - 1] + " " + array[i] + " " + value);
			if(value > x){
				final long diff = Math.min(value - x, array[i]);
				array[i] -= diff;
				answer += diff;
			}
		}
		
		if(array[0] + array[1] > x){
			answer += (array[0] + array[1]) - x;
			array[0] -= (array[0] + array[1]) - x;
		}
		if(array[N - 2] + array[N - 1] > x){
			answer += (array[N - 2] + array[N - 1]) - x;
			array[N - 1] -= (array[N - 2] + array[N - 1]) - x;
		}
		
		System.out.println(answer);
		//System.out.println(Arrays.toString(array));
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 29520
//
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int tt;
    tt = 1;
    while (tt--)
    {
        double d, t, s;
        cin >> d >> t >> s;
        if ((d / s) <= t)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;

int main(){
  ll n, x; cin >> n >> x;
  int a[n];
  REP(i, n) cin >> a[i];

  sort(a, a+n);
  
  int ans = 0;
  for(int i=0; i<n && x >= a[i]; i++){
    x -= a[i];
    ans++;
  }

  if(x != 0 && ans == n) ans--;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int un[100];

int find(int x){
  if(un[x]==x)return x;
  return un[x]=find(un[x]);
}

void unit(int a,int b){
  un[find(a)]=un[find(b)]=find(a);
}

pair<int,PI> in[10000];

main(){
  int n,m;
  while(cin>>n>>m,n|m){
    rep(i,m){
      cin>>in[i].S.F>>in[i].S.S>>in[i].F;
      in[i].S.F--;
      in[i].S.S--;
    }

    sort(in,in+m);

    int ans=1<<28;
    rep(i,m){
      rep(j,n)un[j]=j;
      int maxe=0;
      for(int j=i;j<m;++j){
        if(find(in[j].S.F)==find(in[j].S.S))continue;
        unit(in[j].S.F,in[j].S.S);
        maxe=in[j].F;
      }
      bool ok=true;
      rep(j,n)ok&=find(0)==find(j);
      if(!ok)break;
      ans=min(ans,maxe-in[i].F);
    }
    if(ans==1<<28)ans=-1;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 988
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = sc.nextInt();
		int[] nums = new int[count];

		for(int i = 0; i < count;i++) {
			nums[i] = sc.nextInt();

		}

		for(int i = count - 1;i >= 0 ;i--) {
			System.out.print(nums[i]);
			if(i != 0 ) {
				System.out.print(" ");
			}
		}
		System.out.println();

	}
}

Measured memory_bytes: 26336
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

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

	long long x, y;
	cin >> x >> y;

	int ans = 0;
	while(x <= y){
		x *= 2;
		ans++;
	}
	cout << ans << "\n";
	
	return 0;
}

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

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;
 
#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;

int main() {
  
  int n;
  cin >> n;
  
  int count = 0;
  
  for ( int i = 1; i <= n; i += 2){
    int yaku = 0;
    int a = 1;
    while( a <= i ){
      if ( i % a == 0 ){
        yaku++;
      }
      a++;
    }
    if ( yaku == 8 ){
      count++;
    }
  }
  
  cout << count << endl;

}

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

typedef pair<double,double> P;

#define repl(i,a,b) for(int (i)=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define dbg(x) cout<<#x<<"="<<x<<endl

#define EPS 1e-6

struct line{
  double wi,ai,bi;
  int typ;
};
bool operator<(const line& a,const line& b){
  return a.wi < b.wi;
}

int N;
int pw;
int vw[100010],pf[100010],vf[100010],th[100010];

int main(){
  while(1){
    cin>>N;
    if(N==0)break;
    cin>>pw;
    rep(i,N)cin>>vw[i]>>pf[i]>>vf[i]>>th[i];

    double a=0,b=0;
    vector<line> ls;
    rep(i,N){

      double ai=-(double)pf[i]*((double)vw[i]/(double)vf[i]);
      double bi=(double)pf[i]*((double)th[i]/(double)vf[i]);
      
      if(ai>EPS){ // pos
        double wi=-bi/ai;
        if(wi>EPS){
          ls.push_back((line){wi,ai,bi,+1});
        }else{
          a+=ai;
          b+=bi;
        }
      }else if(ai<-EPS){ // neg
        double wi=-bi/ai;
        if(wi>EPS){
          ls.push_back((line){wi,ai,bi,-1});
          a+=ai;
          b+=bi;
        }else{
      
        }
      }else{
        b+=max(0.0,bi);
      }
    }
    sort(all(ls));
    double res=b;
    rep(i,ls.size()){
      double crtw=ls[i].wi;
      res=min(res,crtw*((double)pw+a)+b);
      if(ls[i].typ==+1){
        a+=ls[i].ai;
        b+=ls[i].bi;
      }else{
        a-=ls[i].ai;
        b-=ls[i].bi;
      }
    }
    printf("%.10f\n", res);
  }

  return 0;
}



Measured memory_bytes: 11604
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>

using namespace std;

int N;

int main() {
	cin >> N;
	vector<int> V(N);
	vector<int> C(N);
	for (int i = 0; i < N; i++) { cin >> V[i]; }
	for (int i = 0; i < N; i++) { cin >> C[i]; }

	vector<int> dVC(N);
	for (int i = 0; i < N; i++) { dVC[i] = V[i] - C[i]; }
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (dVC[i] > 0) { ans += dVC[i]; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ld long double
long long const inf = 1e18;
int const mxn = 2e5+10;
 
ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}
 
 
 
 long long l[mxn],ans;
 
int main(){
	long long n,k;
	cin>>n>>k;
	for (int i = 0;i<n;i++){
	cin>>l[i];
	}
	sort(l,l+n);
	for (int i = 0;i<n-k;i++){
		ans += l[i];
	}
	cout<<ans ;

}

Measured memory_bytes: 1792
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		long n = long.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
		long[] dp = new long[n+1];//iとするための最小操作回数
    dp[0] = 0;

    for(long i = 1; i <= n; i++)
    {
    dp[i] = long.MaxValue;
      for(long divide = 1; divide > 0; divide++)
      {
        if(i-(long)Math.Pow(6, divide) >= 0) 
        {
          dp[i] = Math.Min(dp[i], dp[i-(long)Math.Pow(6, divide)] + 1);
        }else break;
      }
      for(long divide = 1; divide > 0; divide++)
      {
        if(i-(long)Math.Pow(9, divide) >= 0) 
        {
          dp[i] = Math.Min(dp[i], dp[i-(long)Math.Pow(9, divide)] + 1);
        }else break;
      }
      dp[i] = Math.Min(dp[i], dp[i-1] + 1);
    }
    
		Console.WriteLine(dp[n]);
	}
}

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

typedef long long LL;

LL A, B, C, D;
map<LL,LL> dp;

LL solve(LL N) {
    if(N == 0) return 0;
    if(N == 1) return D;

    if(dp.find(N) != dp.end()) return dp[N];
    LL ans = 1e18;
    double lg = log10(N) + log10(D);
    if(lg <= 16) ans = N*D;

    LL x = N%2;
    ans = min(ans, solve(N/2)+x*D+A);
    if(x > 0) ans = min(ans, solve((N+1)/2)+(2-x)*D+A);

    x = N%3;
    ans = min(ans, solve(N/3)+x*D+B);
    if(x > 0) ans = min(ans, solve((N+2)/3)+(3-x)*D+B);

    x = N%5;
    ans = min(ans, solve(N/5)+x*D+C);
    if(x > 0) ans = min(ans, solve((N+4)/5)+(5-x)*D+C);

    return dp[N] = ans;
}

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int tc;
    cin >> tc;
    while(tc--) {
        dp.clear();
        LL N;
        cin >> N;
        cin >> A >> B >> C >> D;
        cout << solve(N) << endl;
    }

    return 0;
}



Measured memory_bytes: 4760
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        sc.close();
        int ans[] = new int[n];
        for (int i = 1; i <= n; i++) {
            for (int j = i; j <= n; j++) {
                int direct = j - i;
                int shortcut = Math.abs(i - x) + 1 + Math.abs(j - y);
                int dist = Math.min(direct, shortcut);
                ans[dist]++;
            }
        }
        for (int i = 1; i < n; i++) {
            System.out.println(ans[i]);
        }
    }
}

Measured memory_bytes: 23636
// 2020-06-23 21:17:58
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
namespace prime {
  bool is_prime(ll n) {
    if(n < 2) return false;
    for(ll i = 2; i * i <= n; i++) {
      if(n % i == 0) return false;
    }
    return true;
  }
  vector<ll> divisors(ll n) {
    vector<ll> res;
    for(ll i = 1; i * i <= n; i++) {
      if(n % i == 0) {
        res.push_back(i);
        if(i != n / i) res.push_back(n / i);
      }
    }
    return res;
  }
  map<ll, int> prime_factors(ll n) {
    map<ll, int> res;
    if(n < 2) return res;
    for(ll i = 2; i * i <= n; i++) {
      while(n % i == 0) {
        res[i]++;
        n /= i;
      }
    }
    if(n > 1) res[n] = 1;
    return res;
  }
};

bool ok(ll n, ll k) {
  if(n == 1) return true;
  if(n < k) return false;
  if(n % k) return ok(n - k * (n / k), k);
  else return ok(n / k, k);
}
void answer() {
  ll n;
  cin >> n;
  vector<ll> ans;
  vector<ll> ks1 = prime::divisors(n);
  for(const ll k : ks1) if(2 <= k && k <= n) {
    if(ok(n, k)) ans.emplace_back(k);
  }
  vector<ll> ks2 = prime::divisors(n-1);
  for(const ll k : ks2) if(2 <= k && k <= n) {
    ans.emplace_back(k);
  }
  sort(ALL(ans));
  ans.erase(unique(ALL(ans)), ans.end());
  cout << ans.size() << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
 
int main()
{
  short ans[3];
  short temp;
  cin>> ans[0];
  cin >> ans[1];
  cin >> ans[2];
  
  temp = ans[0];
  ans[0] = ans[1];
  ans[1] = temp;
  temp = ans[0];
  ans[0] = ans[2];
  ans[2] = temp;
  for(int i = 0; i< 3;i++)
  {
    	cout<<ans[i] << endl;
  }
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "algorithm"

using namespace std;

int main() {
    int N;

    cin >> N;

    vector<int> x(N), y(N);

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

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

    int median = y[N / 2];

    // for (int i = 0; i < N; i++) {

    //     if (i < N / 2) {
    //         cout << x[N / 2 + 1] << endl;
    //     } else {
    //         cout << x[N / 2 - 1] << endl;
    //     }
    // }

    for (int i = 0; i < N; i++) {

        if (x[i] < median) {
            cout << y[N / 2] << endl;
        } else if(x[i] >= median) {
            cout << y[N / 2 - 1] << endl;
        }
    }



}

Measured memory_bytes: 3712